谷歌chrome ajax调用不会在js控制台中显示阿拉伯字符

i am using ajax for data in arabic characters and everything works good , i can store arabic characters to database and i can retrieve arabic characters from database and prints it to the screem and everything works good , but my problem is that when i check javascripte concole on google chrome to check the retriveing data i can't show arabic characters , but the prints as this (this is just example and not all data)

["\u0645\u062f\u064a\u0646\u0629","\u0645\u062f\u064a\u0646\u0629 \u062a\u0627\u0631\u064a\u062e\u064a\u0651\u0629","\u0634\u062e\u0635\u064a\u0651\]

i mean like this

enter image description here

When using JSON, strings are in UTF-8, and special characters are encoded as \u followed by 4 hexadecimal characters.

In your case, if you try to decode that string -- for example, with the first item of your array :

>>> str = "\u0645\u062f\u064a\u0646\u0629";
"مدينة"

I don't read arabic, but this looks like arabic to me :-)

Even if the JSON doesn't look good, it's not what matters : the important thing is that you get your original data back, once the JSON is decoded ; and, here, it seems you'll do.


To get the original, decoded, string in the browser's console (for debugging purposes, I suppose), you should be able to use the same JS library you are using in your application (if any), or the JSON.parse() function (I just tested this in Firefox's console, actually) :

>>> JSON.parse('"\u0645\u062f\u064a\u0646\u0629"');
"مدينة"

Of course, you'll have to write some code to actually output that decoded-value to the browser's console (be it "by hand" or when getting the JSON back from your server) ; but since the browser's console it a debugging tool it seems OK.
By default, the console, as a debugging tool, outputs the raw JSON string it gets from the server -- and, with JSON, special characters are encoded, there is nothing you can do about it (except decode the JSON string and display it yourself, if you need to)


If you want to output the decoded string to the console each time you get a result from your server, you'll have to call JSON.parse() each time you get a result from your server ; and then output it, probably using console.log().

Don't forget to remove that debugging code before distributing your application / uploading it to your production server, though.