javascript - How to correctly send/receive Unicode in XMLHttpRequest -
i trying send string containing ·
character server using xmlhttprequest. using following code set content type in javascript code:
xmlhttpreq.setrequestheader("content-type", "application/x-www-form-urlencoded; charset=utf-8")
now if actual utf-8 value ·
, e.g. using page this one or this one, tells me value should 183, or 0xc2 0xb7 utf-8 hex bytes. see latter being sent server. server, when returns data encodes string "\u00c2\u00b7", or literal bytes 0x5c 0x75 0x30 0x30 0x43 0x32 0x5c 0x75 0x30 0x30 0x42 0x37. response passed json.parse(xmlhttpreq.responsetext)
converts ·
. did Â
come from?
the page utf-8, xmlhttprequest utf-8, document.codeset utf-8, , server response utf-8.
it's problem url encoding, not text encoding. please read this:
http://www.w3schools.com/tags/ref_urlencode.asp
you must url decoding in pure c cgi.
Comments
Post a Comment