Hello all, ive been having strange problems using XMTHTTP to send XML messages to a server and back. I have a page encoded in UTF-8:
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
And my XML messages are UTF-8 encoded:
<?xml version="1.0" encoding="UTF-8"?><ajax-re
quest><add
msg><![CDA
TA[ £ ]]></addmsg></ajax-request
>
Im using the prototype library for managing the XMLHTTP requests, so in Firefox the object im using is this one:
new XMLHttpRequest()
My problem is that when I send a message with a pound sign (£ - unicode 163) which is outside the usual iso-8859-1 set, it becomes encoded as this:
£
Is there a provision in the XMLHTTP object to specify character encoding? I cant seem to find one. It would appear the only available choice is iso-8859-1. You can see this encoding problem in action by doing this browser test. Create an XML file with this content:
<?xml version="1.0" encoding="UTF-8"?><ajax-re
quest><add
msg><![CDA
TA[ £ ]]></addmsg></ajax-request
>
View it in a browser and then change the encoding to "iso-8859-1"; refreshing the page shows the behaviour I am experiencing in my XMLHTTP requests.
Conversely, if i create a static HTML page with a content-type encoding set to UTF-8 and then include the pound sign (£) from my keyboard, the browser renders it as this character: � - switching the encoding to iso-8859-1 renders a correct pound sign (£)! Not quite sure what this means...
So to clarify, can anyone explain what exactly is going on here? And how can I deal with the XMLHTTP encoding problem?
Thanks for your help
Start Free Trial