SQLite C/C++ API unsigned char * SQLite C/C++ API unsigned char * sqlite sqlite

SQLite C/C++ API unsigned char *


From the SQLite documentation:

(H13821) The sqlite3_column_text(S,N) interface converts the Nth column in the current row of the result set for the prepared statement S into a zero-terminated UTF-8 string and returns a pointer to that string.

UTF-8 wants byte values ranging from 0x00 to 0xFF. char can range from -0x80 to 0x7F (signed) or 0x00 to 0xFF (unsigned). Forcing unsigned allows the proper encoding of a UTF-8 string.


At a wild guess I'd say that it has something to do with supporting UTF-8 encoding. Signed char values only make sense in a 7-bit ASCII environment where everything above 0x7f is open to interpretation. In UTF-8 everything between 0x00 and 0xFF can be used equally.