问题描述
我试图用更新的源码行特定的文本列(WVARCHAR) sqlite3_bind_text16()
我的C程序但遗憾的是,只有字符串只包含ASCII恩如 codeD字符LE
正确更新,但含有如 LéUNI code字符的其他字符串
遇到无法正常存储在非ASCII字符更新。我这里是怎么使用的功能:
I'm trying to update a specific text column(WVARCHAR) on sqlite row using sqlite3_bind_text16()
on my C program but unfortunately, only the strings that contains only ascii encoded characters like L"e"
are updated correctly, but the other strings containing unicode characters like L"é"
are updated having the non-ascii characters not stored correctly. here is example how I used the function:
sqlite3_bind_text16(stmt, 1, L"e", -1, SQLITE_STATIC); //e is stored correctly
sqlite3_bind_text16(stmt, 2, L"é", -1, SQLITE_STATIC); //é not stored correctly: modified
我测试了一下使用sqlite的外壳为我的程序的SQLite数据库文件执行SELECT命令。
I tested that by doing select command using sqlite shell for my program's sqlite database file.
那么如何解决这个问题?
so how to fix that?
推荐答案
发出以下 PRAGMA
更新到数据库之前:
Issue the following PRAGMA
to the database prior to updating:
PRAGMA编码='UTF8';
这应该确保SQLite是正确更新非ASCII字符。
This should ensure sqlite is updating non-ASCII characters correctly.
这篇关于SQLite3的:非ASCII字符无法正常更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!