小弟刚接触UNICODE,基本内容算是知道一点点了,很想看看UNICODE和ANSI及其他汉字编码转换的源代码。哪位大哥可以发给我一个相关的程序源代码,先谢谢大家!分不够可以再加,说到做到。

解决方案 »

  1.   

    MultiByteToWideChar// we want to convert an MBCS string in lpszA
    int nLen = MultiByteToWideChar(CP_ACP, 0,lpszA, -1, NULL, NULL);
    LPWSTR lpszW = new WCHAR[nLen];
    MultiByteToWideChar(CP_ACP, 0, 
        lpszA, -1, lpszW, nLen);
    // use it to call OLE here
    pI->SomeFunctionThatNeedsUnicode(lpszW);
    // free the string
    delete[] lpszW;
      

  2.   

    http://www.codeproject.com/cpp/unicode.asp
      

  3.   

    http://www.csdn.net/expert/topic/1050/1050740.xml?temp=.6760065
      

  4.   

    还有就是<<Windows程序设计>>( http://www.wuyou.org/wlbookwl/windowsp5.zip)与<<Windows核心编程>>(www.vckbase.com)讲的很透也有源程序,可以看他们的电子版
      

  5.   

    HRESULT AnsiToUnicode(LPCSTR pszA, LPOLESTR* ppszW)
    {
        ULONG cCharacters;
        DWORD dwError;
        if (NULL == pszA)
        {
            *ppszW = NULL;
            return NOERROR;
        }
        cCharacters =  strlen(pszA)+1;
        *ppszW = (LPOLESTR) CoTaskMemAlloc(cCharacters*2);
        if (NULL == *ppszW)
            return E_OUTOFMEMORY;
        if (0 == MultiByteToWideChar(CP_ACP, 0, pszA, cCharacters,*ppszW, cCharacters))
        {
            dwError = GetLastError();
            CoTaskMemFree(*ppszW);
            *ppszW = NULL;
            return HRESULT_FROM_WIN32(dwError);
        }
        return NOERROR;
    }
      

  6.   

    可用宏啊!他们是A2W和W2A,具体使用方法MSDN有详解!