关于ANSI和Unicode、Unicode和UTF-8等的相互转换
来源:互联网 发布:魔兽传输数据遇到问题 编辑:程序博客网 时间:2024/04/29 08:08
关于ANSI和Unicode、Unicode和UTF-8等的相互转换可通用的代码如下:
qp::StringW Global::AnsiToUnicode(
const
char
* buf)
{
int
len = ::MultiByteToWideChar(CP_ACP, 0, buf, -1, NULL, 0);
if
(len == 0)
return
L
""
;
std::vector<</CODE>wchar_t
> unicode(len);
::MultiByteToWideChar(CP_ACP, 0, buf, -1, &unicode[0], len);
return
&unicode[0];
}
qp::StringA Global::UnicodeToAnsi(
const
wchar_t
* buf)
{
int
len = ::WideCharToMultiByte(CP_ACP, 0, buf, -1, NULL, 0, NULL, NULL);
if
(len == 0)
return
""
;
std::vector<</CODE>char
> utf8(len);
::WideCharToMultiByte(CP_ACP, 0, buf, -1, &utf8[0], len, NULL, NULL);
return
&utf8[0];
}
qp::StringW Global::Utf8ToUnicode(
const
char
* buf)
{
int
len = ::MultiByteToWideChar(CP_UTF8, 0, buf, -1, NULL, 0);
if
(len == 0)
return
L
""
;
std::vector<</CODE>wchar_t
> unicode(len);
::MultiByteToWideChar(CP_UTF8, 0, buf, -1, &unicode[0], len);
return
&unicode[0];
}
qp::StringA Global::UnicodeToUtf8(
const
wchar_t
* buf)
{
int
len = ::WideCharToMultiByte(CP_UTF8, 0, buf, -1, NULL, 0, NULL, NULL);
if
(len == 0)
return
""
;
std::vector<</CODE>char
> utf8(len);
::WideCharToMultiByte(CP_UTF8, 0, buf, -1, &utf8[0], len, NULL, NULL);
return
&utf8[0];
}
- 关于ANSI和Unicode、Unicode和UTF-8等的相互转换
- UNICODE和ANSI间的相互转换
- Unicode和ansi及Utf-8转换
- ansi unicode utf-8相互转换
- ANSI,UNICODE, UTF-8 字符串之间的相互转换
- ANSI,UNICODE, UTF-8 字符串之间的相互转换
- unicode、utf-8、ansi的故事及其相互转换
- 关于Unicode&UTF-8&ANSI的相互转换(Ver1.1)
- windows下utf-8和unicode的相互转换
- Unicode编码和ANSI编码相互转换
- windows核心编程---UNICODE和ANSI间的相互转换
- VC++版 Unicode ANSI UTF-8 GB2312 相互转换代码
- Ascii、ANSI、unicode和utf-8的详解和区别
- ANSI和UNICODE字符的相互转化
- ANSI、ASCII、Unicode和UTF-8编码
- ANSI、ASCII、Unicode和UTF-8编码
- ANSI、ASCII、Unicode和UTF-8编码
- 关于ANSI和unicode
- android利用JNI调用C++自定义类
- 报错:1130-host ... is not allowed to connect to this MySql server
- Google Maps Android API v2 的API Key申请,Authorization failure解决
- 【discuzx2】如何控制帖子列表页中帖子标题的长度?
- vmware linux bridged模式不能上网
- 关于ANSI和Unicode、Unicode和UTF-8等的相互转换
- 安装sql server时出现 “以前进行的程序安装创建了挂起的文件操作。运行安装程序之前,必须重新启动计算机” 这种错误的解决办法
- 数据库中空值引起的一个奇怪问题
- 【Android】AndroidManifest.xml文件解析
- JavaMail发送和接收邮件
- QListView 实现图片thumbnail
- Java序列化的机制和原理
- 第一章 生活在与网络为中心的世界里
- onMeasure和onLayout理解