• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            mantian

            統(tǒng)計

            留言簿(2)

            閱讀排行榜

            評論排行榜

            文字列轉(zhuǎn)換(MultiByteToWideChar)

            函數(shù)如下,使用的時候直接貼在.h文件中就可以了。

            說明:
            iMultiCharSize 默認為-1的時候,null terminated 被計算。
            其他情況下需要將轉(zhuǎn)換后的結(jié)尾置零。

            inline int WINAPI MB2WC(LPCSTR lpcszStr, int iMultiCharSize, LPWSTR lpwszStr, int iBufSize)
            {
                
            int        iMinSize;
                
                ASSERT(lpcszStr 
            != NULL);
                ASSERT(lpwszStr 
            != NULL);

                
            // -1: the string is assumed to be null terminated and the length is calculated automatically. 
                
            // If this value is zero, the function returns the required buffer size, in wide characters,
                
            // and makes no use of the lpWideCharStr buffer. 
                
            //iMinSize = MultiByteToWideChar(g_uConvCodePage, MB_PRECOMPOSED, lpcszStr, -1, NULL, 0);
                iMinSize = MultiByteToWideChar(g_uConvCodePage, MB_PRECOMPOSED, lpcszStr, iMultiCharSize, NULL, 0);

                
            if(iBufSize < iMinSize)
                
            {
                    
            return FALSE;
                }


                
            //  Change the character string to the wide-character (Unicode) string. 
                MultiByteToWideChar(g_uConvCodePage, MB_PRECOMPOSED, lpcszStr, iMultiCharSize, lpwszStr, iMinSize);
                
            //iMinSize = MultiByteToWideChar(g_uCodePage, MB_PRECOMPOSED, lpcszStr, -1, lpwszStr, iMinSize);
                if(iMultiCharSize > 0)            // fix 20090121 because when -1 ,the length is calculated
                {
                    lpwszStr[iMinSize] 
            = 0;
                }


                
            return iMinSize;
            }

            使用實例
            // +++ test WC2MB
             TCHAR szTest[10] = _T("Zhou");
             char chBuffer[256];
             WC2MB(szTest, 2, chBuffer, 256);
             // +++ end test

            嘿嘿。

            有時間吧Strdup版本也弄好了。這樣 用起來就更方便了。

            posted on 2009-01-21 14:56 岳陽 閱讀(3716) 評論(2)  編輯 收藏 引用 所屬分類: 『 VC&MFC 』

            評論

            # re: 文字列轉(zhuǎn)換(MultiByteToWideChar) 2009-01-29 00:49 Nash Tsai

            在 WIN32 開發(fā)可以用 ATL 裡的

            #include <atlconv.h>

            ATL::CA2W(str, CP_UTF8) - UTF8 Multibytes to Unicode
            ATL::CW2A(wstr, CP_UTF8) - Unicode to UTF8 Multibytes  回復(fù)  更多評論   

            # re: 文字列轉(zhuǎn)換(MultiByteToWideChar) 2009-01-30 07:27 岳陽

            謝謝,記下了。

            我是在CE下面,沒有找到類似的定義。
            不過可以參考一下呵。  回復(fù)  更多評論   

            久久久久人妻精品一区二区三区 | 97超级碰碰碰久久久久| 99精品国产免费久久久久久下载| 日本加勒比久久精品| 久久精品人人槡人妻人人玩AV| 久久青青草原精品国产| 久久国产视屏| 亚洲乱码中文字幕久久孕妇黑人| MM131亚洲国产美女久久| 久久综合成人网| 中文字幕日本人妻久久久免费| 国产精品美女久久久m| 人人狠狠综合88综合久久| 成人资源影音先锋久久资源网| 久久久久久噜噜精品免费直播| 久久这里只有精品18| 欧美麻豆久久久久久中文| 97久久超碰国产精品旧版| 伊人久久大香线蕉综合热线| 国产农村妇女毛片精品久久| 久久精品99久久香蕉国产色戒| 久久www免费人成精品香蕉| 国产欧美一区二区久久| 久久综合给合久久狠狠狠97色69 | 欧美黑人激情性久久| 亚洲综合久久夜AV | 久久一本综合| 久久久WWW成人免费毛片| 久久久国产精品福利免费 | 久久九九久精品国产| 国产免费久久精品丫丫| 99久久精品久久久久久清纯| 国产精品久久精品| 久久国产精品一国产精品金尊 | 色欲综合久久躁天天躁| 久久国产三级无码一区二区| 久久久久久久久久免免费精品| 国产精品永久久久久久久久久| 国产AⅤ精品一区二区三区久久| 国产A级毛片久久久精品毛片| 日本免费久久久久久久网站|