c c++中Unicode和AscII进行转化
2012-04-13 10:39
288 查看
WideToAsc(wchar_t *wp,char *p)
{
bool ret = false;
if(wp != NULL)
{
int count = WideCharToMultiByte(CP_ACP,0,wp,-1,0,0,NULL,NULL);
if(count > 0)
{
WideCharToMultiByte(CP_ACP, 0, wp, -1, p, count + 1 , NULL, NULL);
p[count] = '\0';
ret = true;
}
}
return ret;
}
AscToWide(char *p,wchar_t *wp)
{
bool ret = false;
if(p != NULL)
{
int count = MultiByteToWideChar(CP_ACP, 0, p , strlen(p), NULL , 0);
if(count > 0)
{
MultiByteToWideChar(CP_ACP, 0, p , strlen(p), wp , count+1);
wp[count] = '\0';
ret = true;
}
}
return ret;
}
{
bool ret = false;
if(wp != NULL)
{
int count = WideCharToMultiByte(CP_ACP,0,wp,-1,0,0,NULL,NULL);
if(count > 0)
{
WideCharToMultiByte(CP_ACP, 0, wp, -1, p, count + 1 , NULL, NULL);
p[count] = '\0';
ret = true;
}
}
return ret;
}
AscToWide(char *p,wchar_t *wp)
{
bool ret = false;
if(p != NULL)
{
int count = MultiByteToWideChar(CP_ACP, 0, p , strlen(p), NULL , 0);
if(count > 0)
{
MultiByteToWideChar(CP_ACP, 0, p , strlen(p), wp , count+1);
wp[count] = '\0';
ret = true;
}
}
return ret;
}
相关文章推荐
- C++中ASCII、unicode与Utf8之间的相互转化
- C++中ASCII、unicode与Utf8之间的相互转化
- C++字符串之间转化——Unicode字符集
- C/C++中ASCII与Unicode字符串相互转换
- C++字符串完全指引 && 字符编码笔记:ASCII、Unicode、UTF-8、UTF-16、UCS、BOM、Endian (合集)
- C++之编码问题(Unicode,ASCII,本地默认)
- 字符编码简介:ASCII,Unicode,UTF-8,GB2312及Unicode和UTF-8如何转化
- 字符编码简介:ASCII,Unicode,UTF-8,GB2312及Unicode和UTF-8如何转化
- C++之编码问题(Unicode,ASCII,本地默认)
- C++之编码问题(Unicode,ASCII,本地默认)
- vbs实现unicode和ascii的转化
- 编码方式MultiByte(ASCII)与WideChar(UNICODE)的相互转化
- json \u unicode字符串转化 c++
- 使用C++进行Unicode 编程
- 用C/C++进行注释转化
- vbs实现unicode和ascii的转化
- Unicode(UTF16)文件读写终极方案---用C++标准的字节流读取,转化为宽字符(wchar_t),再以字节流写入
- C++学习之路(27)---ASCII,Unicode 和 UTF-8的区别
- C++下Ascii和Unicode
- Unicode(UTF16)文件读写终极方案---用C++标准的字节流读取,转化为宽字符(wchar_t),再以字节流写入