Hacker News new | ask | show | jobs
by ventana 13 days ago
So, one fun consequence of this is that Unicode multi-byte strings (not UTF-8 but something like UTF-32) cannot be stored as strings in sqlite without a huge pain. Not that I ever planned to use multi-byte fixed length encodings, but good to know!

A good moment to appreciate the elegance of UTF-8 which allowed to encode multi-byte characters preserving the semantics of C strings.

2 comments

I guess, but it seems like if your encoding is not ascii compatible its better to just store as a blob anyway. Even without the null issue its not like string functions not expecting utf-32 would give reasonable answers.
Can I ask in which use case you'd want UTF-32 text in a column ?
I won't! But I can imagine a Windows developer (well, UTF-16, not UTF-32, but still NULs are everywhere) who might want to put something like that to the database without proper converting.
Also why would you store UTF-32 in text column when SQLite clearly doesn't support it? The docs show there are only methods to pass UTF-8 or UTF-16 text.

https://sqlite.org/c3ref/bind_blob.html