• <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

            統計

            留言簿(2)

            閱讀排行榜

            評論排行榜

            文字列轉換(MultiByteToWideChar)

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

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

            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 岳陽 閱讀(3714) 評論(2)  編輯 收藏 引用 所屬分類: 『 VC&MFC 』

            評論

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

            在 WIN32 開發可以用 ATL 裡的

            #include <atlconv.h>

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

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

            謝謝,記下了。

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

            国产一区二区精品久久岳| 亚洲综合伊人久久综合| 久久综合狠狠色综合伊人| 天天综合久久久网| 三级三级久久三级久久| 99久久精品费精品国产一区二区| 热99re久久国超精品首页| 中文字幕久久亚洲一区| 99久久无色码中文字幕| 久久精品国产亚洲αv忘忧草| 精品国际久久久久999波多野| 四虎亚洲国产成人久久精品| 国产精品欧美久久久天天影视 | 久久久久久九九99精品| 国产精品成人久久久久久久| 亚洲中文字幕无码久久精品1 | 国产精品伦理久久久久久| 四虎国产精品成人免费久久| 一级做a爱片久久毛片| 亚洲精品乱码久久久久久久久久久久 | 久久久久免费精品国产| 久久亚洲AV无码精品色午夜| 久久精品国产一区二区| 久久99精品久久久久久久久久| 亚洲欧美国产精品专区久久| 国产精品久久久久一区二区三区 | 69久久精品无码一区二区| 2020国产成人久久精品| 久久亚洲电影| 亚洲乱码日产精品a级毛片久久 | 97精品国产97久久久久久免费| 久久久久人妻一区精品果冻| 伊人久久大香线蕉精品| 久久精品国产亚洲77777| 日韩精品久久久久久免费| 无码精品久久久天天影视| 色综合久久久久无码专区| 久久天堂AV综合合色蜜桃网 | 97久久国产综合精品女不卡| 国内精品人妻无码久久久影院导航| 一级做a爰片久久毛片毛片|