加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SQLite C/C++ API unsigned char *

发布时间:2020-12-12 18:59:57 所属栏目:百科 来源:网络整理
导读:为什么SQLite C/C++ API为文本值返回unsigned char * s而不是更实际的char *类型? 这与the unsigned char问题有些相关,除了SQLite API的决定似乎与为类字符串值给出的传统char *建议相反. 例如: const unsigned char *sqlite3_column_text(sqlite3_stmt*,i
为什么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字符串.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读