ralfstx/minimal-json

Unicode signs (like emojis) should be escaped

nbartels opened this issue · 2 comments

I use a Java String with an escaped smiley in it. This looks like:

String message = "That's funny \uD83D\uDE03";

The String is used in a JsonObject and as soon as I print the JsonObject the unicode signs are not escaped as expected. As soon as I use this JsonObject with the Facebook Graph API for example, the missing escaping leads to missing emojis.

Afaik this unicode characters may, but not must be escaped so, this may be a bug ... but perhaps it isn't. Do I have to implement my own JsonWriter?

Right, according to RFC 4627, all unicode characters (except ", /, and control characters) may occur in JSON strings.

Did you make sure that you send the correct HTTP headers for UTF-8 to the server? As a workaround, wouldn't it help to write to a wrapped Writer that transparently encodes unicode chars?

If this solution is unsatisfactory, we should consider a configuration option to minimal-json. But then, would this option escape all characters or just certain Unicode planes?

Okay thanks. I'll try the wrapped Writer first ;)