Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am trying to convert a list to a json sting, that contains a series of Chinese characters. But instead of seeing the actual Chinese text, I am seeing [???]. Is there a way to avoid that?

Thank you.
Posted
Updated 30-Nov-13 22:12pm
v2
Comments
Sergey Alexandrovich Kryukov 1-Dec-13 15:09pm    
Use Unicode in all cases, don't allow any intermediate data to use non-Unicode encoding.
—SA

1 solution

Its best to use unicode encoding - http://tools.ietf.org/html/rfc4627#section-3[^].
 
Share this answer
 
v2
Comments
78ATI 1-Dec-13 2:24am    
Yes, but how do I set it in my code?
Shall I do it while converting toJson(gson.toJson) ?
or there is a more generic way?
Sergey Alexandrovich Kryukov 1-Dec-13 15:12pm    
I'm really sorry, Abhinav, this is not true, not at all. If you supply Unicode is some UTF, and font does not support the code point, it will show something like boxes. If a page assumes different UTF (one UTF is actually used for supplied data, but the page HTTP-EQUIV assumes a different one), there will be a kind of gibberish.

"???" only appears if data was converted to non-UTF encoding anywhere on the road. This is the default conversion for unsupported code point.

—SA
Abhinav S 1-Dec-13 22:23pm    
AH thanks - I was not aware of this subtle difference between boxes and question marks (and of course why they appear).
However, if I do use unicode, I guess it will still solve the problem? I will modify my answer.
Sergey Alexandrovich Kryukov 1-Dec-13 23:00pm    
You see, I already put most of what could be written in response to OP's information, which is by far insufficient. The solution is: never allow any non-UTF encoding on all the path from source to the browser (or whatever it is, we don't really know). Unicode itself is not encoding, but UTFs are. Immediate problem is some step where Unicode data was converted to, most likely, ASCII. If that step is fixed, there could be other problem, we cannot know about them from available information.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900