invalid token error while parsing an XML file with UTF-8 encoding
invalid token error while parsing an XML file with UTF-8 encoding.
This error is coming when it encountered extended ASCII character 'â' { "â", "â" }.
When I have changed the encoding from UTF-8 to ISO-8859-1 the parsing is successful. But my application should support UTF-开发者_Go百科8, ASCII and extended ASCII characters. What should I do for this?
Any ideas are welcome.
Thanks in Advance for your time and solution.
Telling a parser that a latin-1 file is UTF-8 by setting the encoding attribute of the XML declaration will result in an error similar to that which you report.
If the 'â' character (U+00E2) appears in a UTF-8 encoded file, then that character will be encoded in that file as a two byte sequence. So if you are not changing the bytes in the file when you say you are changing the encoding, you are not changing the encoding of the file, only telling the parser that a non-UTF-8 file is UTF-8.
精彩评论