discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Is that gson not support Chinese charaterset? #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When serializing Chinese charater with gson like: gson.toJson('测试'); it 
will return something like "\u6d4b\u8bd5".  Is that gson not support non-
English charaterset?I'm using the gson-1.2.3. Thanks!

Original issue reported on code.google.com by roger.y2...@gmail.com on 10 Dec 2008 at 9:12

GoogleCodeExporter commented 9 years ago
This was a problem before, but was fixed in Issue #23.  See the following 
thread:
http://groups.google.com/group/google-gson/browse_thread/thread/f2094410e2a7f347

In short, \u6d4b\u8bd5 is the unicode equivalent of 测试.

Try the following:
public static void main(String[] args) {
  System.out.println("测试");
  System.out.println("\u6d4b\u8bd5");
}

NOTE: you'll need to save the file as UTF-8

Original comment by joel.leitch@gmail.com on 12 Dec 2008 at 9:38

GoogleCodeExporter commented 9 years ago
We agree with the issue that was raised. Gson should not write escaped unicode 
characters and instead let the underlying writer (passed in toJson()) handle 
the 
character encoding.

Original comment by inder123 on 19 Dec 2008 at 8:46

GoogleCodeExporter commented 9 years ago
Fixed in r342

Original comment by inder123 on 19 Dec 2008 at 8:47