lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello there,

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,

Enrique (@otikik)