|
PHP/AJAX character encoding
I'm trying to transmit binary data via AJAX. The binary data is stored in a normal string, so it's not really binary anymore, but it results in the string containing weird characters.
I save the transmitted data in PHP to a file, that I later want to be able to load again via AJAX.
//string in Javascript
È'marcgfx"ÏÿP
:e5ÿÿÿPesce
to transmit I use escape(txt)
//what gets stored in the file
something that looks chinese, only very few characters compared to the original, so it looks like one character uses multiple bytes
//result (both loaded from file, or echoed in the receiving file of ajax request)
�'marcgfx"��P�:e5���Pesce
any idea what I could be doing wrong? to me it looks like an encoding issue.
The binary data is fine by the way, I just can't get the same string back that I originally sent. I've set headers in both php and html to utf-8, i've set php's mbstring to utf-8, can't think of much else right now.
|