GB2312 与 UTF8 互转
来源:互联网 发布:helloworld代码java 编辑:程序博客网 时间:2024/05/16 14:41
CString CMyTools::G2U(CString 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;
}
CString CMyTools::U2G(CString 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;
}
{
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;
}
CString CMyTools::U2G(CString 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 与 UTF8 互转
- UTF8与GB2312
- utf8 GB2312 互转
- Utf8-Gb2312互转
- UTF8 GB2312互转
- GB2312与UTF8相互转换
- GB2312与UTF8互相转换
- UTF8 GB2312
- 网页编码utf8与gb2312的区别
- vc++ UTF8与gb2312互相转码
- utf8、gb2312与big5互相转换
- gb2312与utf8的手动转换
- utf8与gb2312有什么区别
- vc utf8与gb2312互相转换.
- Linux utf8与gb2312转换函数
- UTF8与GB2312的互转
- c#之utf8和gb2312互转
- c++中Gb2312与utf8互转函数
- 微软资深软件工程师:阅读代码真的很难(1)
- BL指令实际做出的操作
- Hibernate的级联删除
- android中的常用布局
- 微软资深软件工程师:阅读代码真的很难(2)
- GB2312 与 UTF8 互转
- C++实现urlencode
- Linux hbase内存溢出分析
- DAS、NAS、SAN三种存储架构
- Sun JVM内存管理和垃圾回收
- Hibernate实现级联删除
- Ext grid中日期显示为NaN-NaN-NaN 的原因及解决方法
- exchange 2007 dial-tone access
- VC6.0中构建和配置ACE