Hi, everyone This is my first question here. Even though it is far from one of the hard ones I usually ask it is very challenging and has been bugging me for the last couple of hours. Here is the deal: I have a MySql database that keeps non-Latin text in the form of Unicode (correct me if I am wrong, I believe it's Unicode). For example in a table under column "name" instead of "John" one my find: & #1051;& #1086;& #1082;& #1086;& #1084;& #1086;& #1090;& #1080;& #1074; & #1057;& #1086;& #1092;& #1080;& #1103; (without the spaces between & and #) when decoded this string spells "Локомотив" in Cyrillic (google it if you don't believe me). When selected from the database and output directly to the screen with <?php echo $string; ?> it displays properly in decoded format - "Локомотив". But when I make a simple AJAX request with javascript <?php echo $string; ?> returns the encoded version you saw first. What is going on? How come php haven't decoded the string when javascript makes the request? How come php outputs it properly in a browser with Character Encoding set to Western (ISO-8859-1) without any decoding in the first place? Is there a function in php or javascript that can help me decode this row of numbers?
Would this work: $string = urldecode($string) PHP: If not how about: http://us3.php.net/manual/en/function.unicode-decode.php
I'm not entirely sure what the issue is but I can tell you it's not a php problem. PHP is not evolved in converting those codes to their equivalent unicode characters but it is done by the browser. Just try saving the hex codes in a plain html file and you will see them being converted to their unicode characters. It seems for some reason when using javascript on your page the browser is no longer interpreting the hex codes like it usually would. If you could show us the resulting html code that does not work we could probably help you out.