Passing Utf-8 Strings Between Php And Javascript
Solution 1:
The solution was in json_encode
functions. The problems stopped when i added JSON_HEX_APOS|JSON_HEX_QUOT
.
Thanks!
Solution 2:
use json_encode in PHP and receive responses as JSON (jQuery is helpful) ajax is sent in utf-8 by default, so You just have to return utf-8
php's utf8_encode(data) gets an ISO-8859-1 string as the data argument.
need more suggestions? Tell me where You get the text from ;)
Solution 3:
From experience, Javascript's escape() (ant thus unescape()) are not Unicode (UTF-8) friendly. Use encodeURIComponent() and decodeURIComponent() instead.
Anyway, as the docs says:
The escape() function should not be used to encode URIs.
Solution 4:
If php is doing the encoding and js decoding whay not simply not encode in php and encode in js as well? Not really an answer so much as a work around i guess.
Post a Comment for "Passing Utf-8 Strings Between Php And Javascript"