• <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 岳陽 閱讀(3716) 評論(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久久精品66| 久久亚洲国产成人精品无码区| 一本综合久久国产二区| 麻豆久久久9性大片| 色综合久久综合中文综合网| 久久久国产精品网站| 久久精品国产欧美日韩99热| 久久九九全国免费| 亚洲色大成网站www久久九| 亚洲国产二区三区久久| 亚洲精品乱码久久久久久蜜桃图片| 91麻豆精品国产91久久久久久 | 久久精品国产亚洲av麻豆色欲 | 亚洲国产视频久久| 日本精品久久久中文字幕| 久久人妻少妇嫩草AV蜜桃| 狠狠精品久久久无码中文字幕| 亚洲第一极品精品无码久久| 久久综合色之久久综合| 国产成人99久久亚洲综合精品| 久久九九精品99国产精品| 亚洲国产日韩综合久久精品| 久久精品这里只有精99品| 精品久久久久久无码中文字幕一区| 久久亚洲精品国产亚洲老地址| 久久久久这里只有精品 | 久久噜噜久久久精品66| 精品久久久久久久| 精品无码久久久久久尤物| 伊人久久综合成人网| 久久精品极品盛宴观看| 久久亚洲国产精品五月天婷| 国产精品免费久久| 99久久亚洲综合精品成人| 国内精品久久久久| 久久免费视频观看| 久久精品不卡| 国产69精品久久久久APP下载| 久久这里有精品| 久久久一本精品99久久精品66| 国产毛片欧美毛片久久久|