Merlin's Blog
Just record something
Toggle navigation
Merlin's Blog
Home
Scratch基础教程
About Me
Archives
Tags
sqlite3中文乱码问题
2017-01-18 14:57:46
194
0
0
merlin
这两个函数会用就行,需要引入windows.h头文件 ```c++ /// <summary> /// utf-8转换到GB3212 /// <para>utf8 char</para> /// </summary> char* UTF82GB(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; } /// <summary> /// GB2312到UTF-8的转换 /// <para>gb2312 char</para> /// </summary> char* GB2UTF8(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; } ```
Pre:
sqlite3 database is locked
Next:
用sqlite3_prepare_v2使用INSERT
0
likes
194
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Table of content