On 1/10/20 1:43 PM, Tim Streater wrote:
On 10 Jan 2020, at 18:03, Richard Hipp <d...@sqlite.org> wrote:

On 1/10/20, Dominique Devienne <ddevie...@gmail.com> wrote:
There's no way at all, to know the length of a text column with embedded
NULLs?

You can find the true length of a string in bytes from C-code using
the sqlite3_column_bytes() interface.  But I cannot, off-hand, think
of a way to do that from SQL.
But if I store UTF-8 in a TEXT column, surely I'm allowed to include NULLs in 
that? They are after all valid UTF-8 characters.



As has been said, C Strings (which is what TEXT is assumed to hold) are not allowed to include null characters, but are assumed to terminate at the first 0 bytes. There is a variant of UTF-8, called modified UTF-8 or MUTF-8, which allows a null character to be encoded as C0 80, which does decode to 0 by the base UTF-8 rules, but is disallowed by the minimum encoding rule, which can be used to embed nulls in strings if the system doesn't enforce the minimum length encoding rule (at least for this character).

I have no idea if that would work with SQLite though.

--
Richard Damon

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to