Suppose \u4404 means 'A' in Japanese. Following code will print 'A' on screen.
String str = "\u4404";
System.out.println(str);
This is true because encode("\u4404", unicode)='A'
.
But I encountered one problem. When I process a message received over http, I get following output like
{"name":"\u4404\u2424\u4022","age":"30"}
The http header shows the reply is encoded by utf-8. But why does the ouput shows like this?
Here is my guess:
Suppose the stream I received from web is mystream
. Then, after we encode mystream
with utf-8
, I get \u4404\u2424\u4022
. I have to encode mystream
by TWO times, and get the right 'A' in Japanes.
Am I right? If i am right, why transfer data like this? Because of JSON? Thans very much for your ansewer!