Sqlite c++操作数据库中文乱码

char* Utf2Gb(const char* utf8)

{

int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);

wchar_t* wstr = new wchar_tlen + 1;

memset(wstr, 0, len + 1);

MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wstr, len);

len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);

char* str = new charlen + 1;

memset(str, 0, len + 1);

WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, len, NULL, NULL);

if (wstr) delete\[\] wstr;

return str;

}

//GB2312到UTF-8的转换

char* GB2Utf(const char* gb2312)

{

int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);

wchar_t* wstr = new wchar_tlen + 1;

memset(wstr, 0, len + 1);

MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);

len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);

char* str = new charlen + 1;

memset(str, 0, len + 1);

WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);

if (wstr) delete\[\] wstr;

return str;

}

相关推荐
choumin34 分钟前
创建型模式——工厂方法模式
c++·设计模式·工厂方法模式·创建型模式
云小逸1 小时前
【SVN 详细使用指南:从入门到团队协作】
c++·svn
kirs_ur1 小时前
ECC & LDPC — SSD 的数据卫士
服务器·数据库·性能优化
是三一seven2 小时前
Sql注入基础
数据库·安全·网络安全
Sirens.2 小时前
MySQL表设计进阶-约束范式连接索引与事务
android·数据库·mysql
字节跳动开源3 小时前
火山引擎开源 Agent 驱动的搜索自迭代技术
数据库·开源·agent
Oo大司命oO5 小时前
藏在正则表达式里的陷阱
数据库·mysql·正则表达式
ziguo11226 小时前
深入浅出 C/C++ 数据类型:从入门到踩坑
linux·c语言·c++·windows·visual studio
_oP_i6 小时前
mysql统计数据库使用存储大小
数据库
白色冰激凌7 小时前
[SECS/GEM研究] (三)SECS-I 串口上消息怎么分块和重传
c++·secs/gem