unicode 的体会
来源:互联网 发布:淘宝账号在哪里查看 编辑:程序博客网 时间:2024/05/12 05:52
关于windows下使用的函数:
1:windows api 涉及到字符串参数的 ANSI版本函数,均是在函数内部转换为 unicode,然后使用unicode版本函数进行调用,来完成函数功能,所以使用windows api使用 unicode较好。
2:ansi 函数有unicode版本的函数,但是其内部是把unicode转换为 ansi c单字节,使用,故调用ansi c函数,则使用ansi 编码较好
这样做,估计是为了稳定。
unicode 部分编码:
UTF-8:
0x00 - 0x7f 1B
0x008f - 0x07ff 2B
0X0800 - 0XFFFFFF 3B
4B
节省空间,适合于网络传输
UTF-16:
windows 标准
2B 4B
中庸之道。
UTF-32:
统一4字节,解码快,内存占用多,一般在本地使用
//code
// from ansi to unico
void CStringTostring(CString theCString, std::string &thestring, DWORD theType){
int len = WideCharToMultiByte(theType, 0, theCString, -1, NULL, 0, NULL, NULL);
char* pCxml = new char[len + 1];
len = WideCharToMultiByte(theType, 0, theCString, theCString.GetLength(), pCxml, len + 1, NULL, NULL);
pCxml[len] = 0;
std::string tString(pCxml);
thestring = tString;
delete[] pCxml;
}
void stringToCString(std::string thestring, CString &theCString, int theType))
{
int len = MultiByteToWideChar(theType, 0, thestring.c_str(), -1, NULL, 0);
WCHAR* pCxml = new WCHAR[len + 1];
len = MultiByteToWideChar(theType, 0, thestring.c_str(), thestring.length(), pCxml, len);
pCxml[len] = 0;
CString tString(pCxml);
theCString = tString;
delete[] pCxml;
}
0 0
- unicode 的体会
- 体会Unicode编码
- 体会的体会vh
- 学习C#的体会
- 在工作中的一点体会
- 公司管理的体会
- 公司管理的体会
- 公司管理的体会
- 统计分析的体会
- prototype源码的体会
- TrackBack的初次体会
- 升级内存的体会
- 做课程设计的体会
- 一个项目经理的体会
- 体会SALES的“三个代表”
- 驱动的一点体会
- 体会内存的释放
- 学软件的体会
- MyEclipse经常弹出An internal error occurred during: "HTML Syntax Validator". 处理办法
- SQL中Group By的使用
- 一亩三分地
- 语音识别中的置信度问题
- 13-14寒假作业3
- unicode 的体会
- hdu 1002 要用数组计算,错了n次!!!
- 关于 织梦dedeCMS 仿站时遇到的一个问题 “下一遍”“上一遍”逻辑错误
- ORACLE WITH AS 用法
- TreeSet使用中的两种比较方式
- [数据结构]二叉树
- 【Android】屏幕适配——屏幕规格与分辨率对照表
- GridView
- Ubuntu安装独立显卡驱动教程