loveamy / duilib

Automatically exported from code.google.com/p/duilib
0 stars 1 forks source link

CRichEditUI 有些输入法,在ANSI下输入中文乱码问题 #54

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

版本: SVN326
修改: CRichEditUI Line:2182 加入下面代码
if (uMsg == WM_CHAR)
    {
        #ifndef _UNICODE
        unsigned char ch = (unsigned char)wParam;
        if (ch >= 0x81 && ch <= 0xFE && pTxtCache[0] == 0)
        {
            pTxtCache[0] = ch;
            return 0;
        }

        if (pTxtCache[0] != 0 && ch >= 0x40 && ch <= 0xFE)
            pTxtCache[1] = ch;
        else
        {
            pTxtCache[0] = ch;
        }

        int iLen = _tcslen((char *)pTxtCache);
        LPWSTR lpText = new WCHAR[iLen + 1];
        ::ZeroMemory(lpText, (iLen + 1) * sizeof(WCHAR));
        ::MultiByteToWideChar(CP_ACP, 0, (char *)pTxtCache, -1, (LPWSTR)lpText, iLen) ;

        wParam = (WPARAM)lpText[0];
        memset(pTxtCache, 0, 3);
        #endif
    }

pTxtCache为全局变量
unsigned char pTxtCache[3] = {0, 0, 0};

注意:这里只对GBK汉字做了处理。

Original issue reported on code.google.com by yzx822...@sohu.com on 24 Aug 2012 at 6:44