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;

}

相关推荐
leaves falling1 分钟前
C++ string 类:从入门到模拟实现
开发语言·c++
Nontee22 分钟前
Redis高可用架构解析
数据库·redis·架构
样例过了就是过了23 分钟前
LeetCode热题100 柱状图中最大的矩形
数据结构·c++·算法·leetcode
淼淼爱喝水29 分钟前
DVWA SQL 注入(Medium/High 级别)过滤绕过与防范实验(超详细图文版)
数据库·sql·网络安全
csdn_aspnet30 分钟前
MySQL主从延迟根因诊断法,从网络、IO、SQL到参数,系统化定位高并发下的同步瓶颈
数据库·mysql·主从
SHANGHAILINGEN1 小时前
NM | FungAMR数据库,一键筛查真菌耐药基因!
数据库
liuyao_xianhui1 小时前
优选算法_最小基因变化_bfs_C++
java·开发语言·数据结构·c++·算法·哈希算法·宽度优先
牢七1 小时前
jfinal_cms-v5.1.0
数据库
m0_612535991 小时前
redis入门到精通
数据库·redis·缓存
Kethy__2 小时前
计算机中级-数据库系统工程师-数据结构-树与二叉树(2)
数据结构·数据库·软考··计算机中级