Nul Characters in Strings in SQLite
3 hours ago
- #string handling
- #SQLite
- #NUL characters
- SQLite supports storing NUL characters within string values, but this can cause unexpected behavior, such as functions like length() and quote() only processing up to the first NUL.
- The CLI's .dump command and output omit text after the first NUL character, which can be misleading as seen in an example where a string appears shorter than it actually is.
- To detect embedded NULs, use the instr() function, and to remove them along with following text, apply an UPDATE statement with substr() and instr().