[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: How do I make sure that a string is compatible with JSON (utf-8/16/32)?
- From: Enrique Garcia Cota <kikito@...>
- Date: Fri, 27 Sep 2013 12:55:59 +0200
In my current setup I'm treating some strings in Lua and then storing them in JSON.
JSON expects strings in either UTF-8, UTF-16, UTF-32, in big endian or little-endian. Binary blobs outside that is considered invalid.
Unfortunately, some of the data I'm receiving can be binary. I need to detect those cases and escape the binary data somehow (probably with Base64 encoding).
The first step is detecting that a string is binary in the first place.
My unicode knowledge is limited. I know how to get the codepoint by looking at the first bytes of the string. Is parsing the whole string and checking for inconsistencies the way to go?
Thanks a lot,