MultiByteToWideChar 和 WideCharToMultiByte 中第1个参数的理解

来源:互联网 发布:java流程引擎开发原理 编辑:程序博客网 时间:2024/05/12 15:20

MultiByteToWideChar 和 WideCharToMultiByte 中第1个参数的理解

MSDN说:Specifies the code page to be used to perform the conversion,

我的理解是:这2个都是多字符集中的某一个(如ansi或是utf-8)转成宽字符(unicode),

如:

int   len=MultiByteToWideChar(CP_UTF8,0,str,-1,0,0);//请求WCHAR字符数
以上是代表“多字符集”转成“宽字符,这个多字符为UTF-8 ,好理解吧?呵呵

 

::MultiByteToWideChar(CP_ACP, NULL, szAnsi, strlen(szAnsi), wszString, wcsLen);
以上是 将 多字符集转成宽字符,,这个多字符集中的哪一个呢?CP_ACP来告诉你,是ansi。

 

 ::WideCharToMultiByte(CP_ACP, NULL, wszString, wcslen(wszString), szAnsi, ansiLen, NULL, NULL);
意思是:将宽字符 转成 多字符集中的ansi

 

::WideCharToMultiByte(CP_UTF8, NULL, wszString, wcslen(wszString), szU8, u8Len, NULL, NULL);
意思是:将宽字符 转成 字符集中的UFT-8码

特此记录,不混乱!

0 0
原创粉丝点击