• <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下面,沒有找到類似的定義。
            不過可以參考一下呵。  回復  更多評論   

            国产999精品久久久久久| 成人亚洲欧美久久久久| 久久r热这里有精品视频| 久久五月精品中文字幕| 国产成人精品白浆久久69| 久久男人AV资源网站| 久久久久亚洲AV无码麻豆| 久久久青草青青国产亚洲免观| 人妻无码久久一区二区三区免费| 久久综合九色综合欧美狠狠| 一本一道久久a久久精品综合 | 2020最新久久久视精品爱 | 2021精品国产综合久久| 欧美精品一区二区久久| 久久亚洲国产中v天仙www| 亚洲色欲久久久综合网| 久久青青草原精品国产软件| 91久久精品电影| 91精品国产综合久久婷婷| 2021国内久久精品| 香港aa三级久久三级老师2021国产三级精品三级在 | 97超级碰碰碰碰久久久久| 色婷婷久久综合中文久久蜜桃av| 久久综合伊人77777| 99久久精品免费看国产一区二区三区| 久久久久久毛片免费播放| 久久精品国产亚洲AV久| 亚洲精品NV久久久久久久久久| 国产激情久久久久影院| 91精品无码久久久久久五月天| 成人久久综合网| 国产一久久香蕉国产线看观看| AAA级久久久精品无码片| 浪潮AV色综合久久天堂| 久久久久人妻精品一区二区三区| 伊人久久综合精品无码AV专区| 亚洲综合久久夜AV | 亚洲精品无码久久久| 欧美精品国产综合久久| 麻豆精品久久久久久久99蜜桃| 怡红院日本一道日本久久|