SQLite Forum

null character sorts greater than 0x7f and less than 0x80
Login
[Modified UTF-8](https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8), which describes the modification as representation of the null byte as "the two-byte overlong encoding 11000000 10000000 (hexadecimal C0 80)", says that Tcl uses that overlong encoding for internal representation of Unicode data but uses strict [CESU-8](https://en.wikipedia.org/wiki/CESU-8) (which "does not have the special encoding of the NUL character") for external data.	If these Wikipedia-claimed facts are true, then I think that the TCL SQLite library should be storing the null byte, (however it may be represented internal within the TCL runtime engine), as a simple null byte when UTF-8 is the chosen encoding.  For that reason, I think the OP's report indicates a SQLite bug because, in effect, it causes TCL with the SQLite library to deviate from that implied promise.

Of course, this is merely a semantic analysis; it says nothing about the merits of having the SQLite representation of a null byte act like a TCL internal representation.