Reputation: 730
Currently I have Javascript generating XML with an encoding set to UTF-8, and we've run into a situation where we occasionally have some international characters present in the XML. For example:
<?xml version="1.0" encoding="UTF-8"?>
<example>
<comments><![CDATA[Hola. Mi nombre es Pat. ¿Cómo puedo ayudarle?]]></comments>
</example>
Leaving the international characters like this gives us an encoding error when opened in a browser. Changing the XML encoding to the ISO standard, resolves the problem, but we are concerned that the recipients of the XML will be unable to read it properly if the encoding is different. Currently our solution is to esacpe these characters like so:
<?xml version="1.0" encoding="UTF-8"?>
<example>
<comments><![CDATA[Hola. Mi nombre es Pat. ¿Cómo puedo ayudarle?]]></comments>
</example>
My questions is, is this the correct way to go about escaping these characters?
Upvotes: 1
Views: 1722
Reputation: 36
you write that Javascript is generating XML with an encoding set to UTF-8. How do you do this?
Did you check that the resulting file is really UTF-8 encoded? I kind of doubt it - if it was you would not have any trouble, right? My guess is that you specify the encoding in the XML file as encoding="UTF-8" but the files encoding is not really utf-8.
Best, Ronald
Upvotes: 2