• <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>
            隨筆 - 96  文章 - 255  trackbacks - 0
            <2008年4月>
            303112345
            6789101112
            13141516171819
            20212223242526
            27282930123
            45678910

            E-mail:zbln426@163.com QQ:85132383 長期尋找對戰略游戲感興趣的合作伙伴。

            常用鏈接

            留言簿(21)

            隨筆分類

            隨筆檔案

            SDL相關網站

            我的個人網頁

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 493186
            • 排名 - 39

            最新評論

            閱讀排行榜

            評論排行榜

            Windows only. Linux needn't.

            //UVi Soft ( 2008 )
            //Long Fei ( lf426 ), E-mail: zbln426@163.com
            //Laboratory of ZaiBieLiunNian
            //http://m.shnenglu.com/lf426/

            //FileName: gb2312_to_Unicode.h
            //For Windows only


            #ifndef GB2312_TO_UNICODE_H_
            #define GB2312_TO_UNICODE_H_

            #include 
            <iostream>
            #include 
            <vector>
            #include 
            "GNU/iconv.h"

            //if not include "SDL/SDL.h"
            #ifndef _SDL_H
            typedef unsigned 
            short int Uint16;
            #endif

            bool getUnicode(const std::string& str, std::vector<Uint16>& unicodeVectorArray);

            #endif

            //UVi Soft ( 2008 )
            //Long Fei ( lf426 ), E-mail: zbln426@163.com
            //Laboratory of ZaiBieLiunNian
            //http://m.shnenglu.com/lf426/

            //FileName: gb2312_to_Unicode.cpp
            //For Windows only

            #include 
            "gb2312_to_Unicode.h"

            int myUTF8_to_UNICODE(Uint16* unicode, unsigned char* utf8, int len);

            bool getUnicode(const std::string& str, std::vector<Uint16>& unicodeVectorArray)
            {
                
            const int CHAR_SIZE = 256;
                
            //GB2312 src
                const unsigned char* src = (const unsigned char*)(str.c_str());
                size_t src_len 
            = strlen((char*)src);
                
            //Unicode dst to get
                unsigned char dst[CHAR_SIZE] = {0};
                size_t dst_len 
            = sizeof(dst);
                
            //iconv arg
                const unsigned char* in = src;
                unsigned 
            char* out = dst;

                iconv_t cd;
                
            //GB2312 to UTF-8
                cd = iconv_open("UTF-8""GB2312");
                
            if ((iconv_t)-1 == cd){
                    
            return false;
                }
                
            //conversion
                iconv(cd, (const char**)&in&src_len, (char**)&out&dst_len);

                
            //UTF-8 to Unicode
                int utf8Len = strlen((char*)dst);
                Uint16 unicodeData[CHAR_SIZE] 
            = {0};
                
            int unicodeLen = myUTF8_to_UNICODE(unicodeData, dst, utf8Len);
                
            for (int i = 0; i < unicodeLen; i++) {
                    unicodeVectorArray.push_back(unicodeData[i]);
                }
                
                iconv_close(cd); 
                
            return true;
            }

            int myUTF8_to_UNICODE(Uint16* unicode, unsigned char* utf8, int len)
            {
                
            int length;
                unsigned 
            char* t = utf8;

                length 
            = 0;
                
            while (utf8 - t < len){
                    
            //one byte.ASCII as a, b, c, 1, 2, 3 ect
                    if ( *(unsigned char *) utf8 <= 0x7f ) {
                        
            //expand with 0s.
                        *unicode++ = *utf8++;
                    }
                    
            //2 byte.
                    else if ( *(unsigned char *) utf8 <= 0xdf ) {
                        
            *unicode++ = ((*(unsigned char *) utf8 & 0x1f<< 6+ ((*(unsigned char *) (utf8 + 1)) & 0x3f);
                        utf8 
            += 2;
                    }
                    
            //3 byte.Chinese may use 3 byte.
                    else {
                        
            *unicode++ = ((int) (*(unsigned char *) utf8 & 0x0f<< 12+
                            ((
            *(unsigned char *) (utf8 + 1& 0x3f<< 6+
                            (
            *(unsigned char *) (utf8 + 2& 0x3f);
                        utf8 
            += 3;
                    }
                    length
            ++;
                }

                
            *unicode = 0;
                
                
            return (length);
            }

            lib: iconv.lib
            dll: iconv.dll

            last update: 2008-05-12
            posted on 2008-04-14 13:23 lf426 閱讀(2571) 評論(0)  編輯 收藏 引用 所屬分類: mySDL_GameEngine
            久久亚洲AV无码精品色午夜麻豆 | 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区| 日本亚洲色大成网站WWW久久| 色欲综合久久躁天天躁| 亚洲综合伊人久久综合| 久久精品一区二区| 一本色综合久久| 伊人久久大香线蕉影院95| 久久亚洲国产成人影院| 97超级碰碰碰碰久久久久| 久久久久精品国产亚洲AV无码| 精品久久8x国产免费观看| 久久综合久久性久99毛片| 久久97精品久久久久久久不卡| 久久伊人中文无码| 久久久综合九色合综国产| 亚洲精品无码专区久久久| 久久亚洲国产成人影院网站| 久久99久久99精品免视看动漫| 久久成人精品| 久久精品国产一区| 97热久久免费频精品99| 亚洲精品乱码久久久久久按摩 | 一级做a爰片久久毛片毛片| 久久久久久久综合日本亚洲| 人妻无码中文久久久久专区| 久久免费大片| 久久国产香蕉视频| 中文精品久久久久国产网址| 亚洲国产精品无码久久久不卡| 久久亚洲中文字幕精品一区四| 久久777国产线看观看精品| 亚洲国产另类久久久精品黑人 | 亚洲国产天堂久久综合| 精品综合久久久久久88小说| 日本福利片国产午夜久久| 狠狠色丁香久久婷婷综| 久久精品国产99国产电影网| 久久久无码一区二区三区| 狠狠精品久久久无码中文字幕| 欧美伊人久久大香线蕉综合|