~$ 存档

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

多字节转Unicode

四步:

Step1  

#include <iostream>
#include "windows.h"
using namespace std;

void ANSIToUnicode(const char str[])
{
    //获取持转换的字符个数
    int unicodeLen = MultiByteToWideChar( 
        CP_ACP,
        0,
        str,
        -1,
        NULL,
     0 );
//分配宽字符内存 wchar_t * pUnicode = new wchar_t[unicodeLen]; //多字节->宽字符 MultiByteToWideChar( CP_ACP, 0, str, -1, pUnicode, unicodeLen ); /* ...对生成结果进行处理 ...*/ delete []pUnicode; } int main() { char msg[]="M11中文网"; ANSIToUnicode(msg); return 0; }

 

posted on 2017-12-26 15:57  LuoTian  阅读(2899)  评论(0)    收藏  举报