用MultiByteToWideChar
char* mbs = "中国,你好!I Love You!";
int lengthOfWcs = MultiByteToWideChar( CP_ACP, 0, mbs, -1, NULL, 0 );
wchar_t* wcs = new wchar_t[ lengthOfWcs ];
MultiByteToWideChar( CP_ACP, 0, mbs, -1, wcs, lengthOfWcs );
delete wcs;
wcs = NULL;

解决方案 »

  1.   

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx
      

  2.   

    #include   "atlconv.h " 
    打开它看看
      

  3.   

    string str = "巴西世界杯";
    const char *szProgID = str.c_str();
    WCHAR szWideProgID[128];
    long lLen = MultiByteToWideChar(CP_ACP,0,szProgID,strlen(szProgID),szWideProgID,sizeof(szWideProgID));
    szWideProgID[lLen] = '/0'; 
      

  4.   

    string s = "hahaha" 
    //ansi转unicode
    USES_CONVERSION
    A2T(s.c_str());
      

  5.   

    string s = "hahaha";
    首先将MultiByteToWideChar()的最后一个参数设为0,即可返回所需的宽字符数组空间的个数(字符个数,而不是字符空间byte):
      DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, s.c_str(), -1, NULL, 0);
      
      接下来,分配响应的数组空间:
      wchar_t *pwszText = new wchar_t[dwNum+1];
      
      接着就可以着手进行转换了
      MultiByteToWideChar (CP_ACP, 0, s.c_str(), -1, pwszText , dwNum);  最后,使用完毕要记得释放占用的内存:
      delete []pwszText;PS:
    如果你确定string s 的字符串空间不会超过某个值,宽字符可以直接写死,如wchar_t wszText [64] = {0};