GB2312与UTF8互相转换
来源:互联网 发布:js数字拆分成数组 编辑:程序博客网 时间:2024/05/21 05:43
void GBToUTF8(const std::string& gb_str, std::string& result){ // 获得临时变量的大小 int str_len = MultiByteToWideChar(CP_ACP, 0, gb_str.c_str(), -1, NULL, 0); WCHAR *src_str = new WCHAR[str_len + 1]; MultiByteToWideChar(CP_ACP, 0, gb_str.c_str(), -1, src_str, str_len); // 获得临时变量的大小 str_len = WideCharToMultiByte(CP_UTF8, 0, src_str, -1, NULL, 0, NULL, NULL); char *dst_str = new char[str_len + 1]; WideCharToMultiByte(CP_UTF8, 0, src_str, -1, dst_str, str_len, NULL, NULL); result = dst_str; delete[]src_str; delete[]dst_str;}void UTF8ToGB(const std::string& utf8_str, std::string& result){ // 获得临时变量的大小 int str_len = MultiByteToWideChar(CP_UTF8, 0, utf8_str.c_str(), -1, NULL, 0); WCHAR *src_str = new WCHAR[str_len + 1]; ZeroMemory(src_str, sizeof(WCHAR)*(str_len + 1)); MultiByteToWideChar(CP_UTF8, 0, utf8_str.c_str(), -1, src_str, str_len); // 获得临时变量的大小 str_len = WideCharToMultiByte(CP_ACP, 0, src_str, -1, NULL, 0, NULL, NULL); char *dst_str = new char[str_len + 1]; WideCharToMultiByte(CP_ACP, 0, src_str, -1, dst_str, str_len, NULL, NULL); result = dst_str; delete[]src_str; delete[]dst_str;}
1 0
- GB2312与UTF8互相转换
- utf8、gb2312与big5互相转换
- vc utf8与gb2312互相转换.
- GB2312和 UTF8的互相转换函数
- vc++ UTF8与gb2312互相转码
- GB2312与UTF8相互转换
- 字符编码转换(UTF8,UNICOD,GB2312。。。。。互相转换)
- gb2312与utf8的手动转换
- Linux utf8与gb2312转换函数
- UTF8 - GB2312转换
- UTF8、GB2312相互转换
- GB2312 与 UTF8 互转
- UTF8与GB2312
- c语言下的gb2312和utf8及unicode之间的互相转换
- UTF8与GB2312之间转换的工具函数
- gb2312与UTF-8之间的互相转换
- url 编码转换(utf8 - gb2312)
- url 编码转换(utf8 - gb2312)
- MAC OS下查看静态链接库的Version
- 人脸数据库汇总
- 多个Ativity值传递FLAG_ACTIVITY_FORWARD_RESULT
- 安装protocolbuffer详解
- 打包文件 MANIFEST.MF 功能详解
- GB2312与UTF8互相转换
- LCA模板
- ListView侧滑效果
- linux shell 编程笔记 - 文件安全与权限
- C语言学习-编程启蒙思想与算法初识
- 《代码整洁之道》读书笔记
- intellij idea 建立与src级别的目录
- MFC混用QT
- flume1.6.0源码编译