我已经从一个ansi文本中获得了该文本中的字符串,并存在str中。
现在我想用MultiByteToWideChar()这个函数将str转换成unicode编码。
请问各位怎样去实现?
最好能给些代码!

解决方案 »

  1.   

    试试这个:
    dim s as string
    s=strconv(mstr,vbUnicode)顺便说一句,不要用vb的函数名做变量名
      

  2.   

    sorry 看错了,以为是vb版呢
      

  3.   

    CStringW CMyUtility::GetCStringW(const CStringA &ansiString)
    {
    USES_CONVERSION;
    return (A2W(ansiString));
    }
    orCStringW CMyUtility::GetCStringW2(const CStringA &ansiString)
    {
    int iLen = ansiString.GetLength() + 1;
    wchar_t *pUnicode = new wchar_t[iLen];
    MultiByteToWideChar(CP_ACP, 0, ansiString, -1, pUnicode, iLen);
    CStringW strResult;
    strResult.Format(_T("%s"), pUnicode);
    delete []pUnicode; return strResult;
    }
      

  4.   

    看这里吧:
    http://www.lihuasoft.net/article/show.php?id=2346
      

  5.   

    BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)
    {
    // Get the required size of the buffer that receives the Unicode 
    // string. 
    DWORD dwMinSize;
    dwMinSize = MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, NULL, 0); if(dwSize < dwMinSize)
    {
    return FALSE;
    }
    memset(lpwszStr,0,sizeof(lpwszStr));
    // Convert headers from ASCII to Unicode.
    MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, lpwszStr, dwMinSize);  
    return TRUE;
    }