johnezang/JSONKit — Issue #51: Why is Unicode NULL codepoint invalid?
Author: adamjernst
Created: 2011-10-12 16:33:14+00:00
State: open

Why is the Unicode NULL codepoint, when properly escaped, invalid? That is, a string like `"Testing\u0000Hello world"`

`isValidCodePoint` returns `sourceIllegal` for the NULL character (`ch == 0U`). The headers say:

The code in isValidCodePoint() is derived from the ICU code in
utf.h for the macros U_IS_UNICODE_NONCHAR and U_IS_UNICODE_CHAR.

However, `U_IS_UNICODE_CHAR(0)` returns true.

In addition, RFC 4627 makes a passing reference to U+0000 as being allowed:

> Any character may be escaped. If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF), then it may be represented as a six-character sequence

I can of course use the LooseUnicode option to replace it, but that's not ideal since it is valid JSON as far as I can tell.