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;

}

相关推荐
打工的小王33 分钟前
postgresql和mysql对比
数据库·mysql·postgresql
敲上瘾2 小时前
Qt核心机制:信号与槽详解
开发语言·c++·qt·ui·qt6.3
数据库急诊室_阿哲2 小时前
一次割接后的性能复核记录:基线、样本、回滚点
运维·数据库·dba
保利威视频SaaS小张3 小时前
企业直播接入笔记 12|企业内训直播怎么做签到和学时统计,防挂机这件事比想象中难
java·前端·数据库·笔记·视频云·polvy·polyv
牢姐与蒯3 小时前
cpp算法之哈希
c++·算法·哈希算法
lcj25114 小时前
[C++] C++11
开发语言·c++·笔记
顧棟4 小时前
【ES实战】 索引模板「可追溯、可校验」:一种模板治理的工程化思路
java·数据库·elasticsearch
Decay__5 小时前
SQLServer 监控体系构建 —— sql_exporter + Prometheus + Grafana 全栈实战
运维·数据库·sql·mysql·架构
一条大祥脚5 小时前
Agent Memory 全解析:从 SQLite、向量库 + RAG 到 Zep、Mem0
sqlite·agent·rag·智能体记忆
tianyuanwo6 小时前
NocoDB 系统手册:PostgreSQL 主机资产管理的界面层实施方案
数据库·postgresql·oracle