为什么sqlite C/C++ API为文本值返回unsigned char * s而不是更实际的char *类型?
这与the unsigned char问题有些相关,除了sqlite API的决定似乎与为类字符串值给出的传统char *建议相反.
例如:
const unsigned char *sqlite3_column_text(sqlite3_stmt*,int iCol);
解决方法
从
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希望字节值范围从0x00到0xFF. char的范围可以是-0x80到0x7F(有符号)或0x00到0xFF(无符号).强制无符号允许正确编码UTF-8字符串.
@H_404_36@