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

char* Utf2Gb(const char* utf8)

{

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

wchar_t* wstr = new wchar_t[len + 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 char[len + 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_t[len + 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 char[len + 1];

memset(str, 0, len + 1);

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

if (wstr) delete[] wstr;

return str;

}

相关推荐
014-code16 分钟前
CompletableFuture 实战模板(超时、组合、异常链处理)
java·数据库
运气好好的16 分钟前
怎样开启phpMyAdmin的操作审计日志_记录每条执行的SQL
jvm·数据库·python
それども1 小时前
DELETE 和 TRUNCATE TABLE区别
java·数据库·mysql
wenha1 小时前
数据库隔离级别
数据库·mysql·sqlserver·隔离级别
2401_871492851 小时前
Layui如何修改Layui默认的UI主题颜色(换肤功能实现)
jvm·数据库·python
张健11564096482 小时前
使用信号量限制并发数量
开发语言·c++
Edward111111112 小时前
4.27mysql ,数据库,数据源
数据库·mysql
jc06202 小时前
6.1云原生之Docker
c++·docker·云原生
小徐敲java2 小时前
踩坑实录:MySQL8.0 导入SQL报错 2006 - MySQL server has gone away 完美解决
数据库·sql
别来无恙blwy2 小时前
windows MongoDB升级-自动升级脚本-自动检测升级到任意版本
数据库·windows·mongodb