• <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年2月>
            272829303112
            3456789
            10111213141516
            17181920212223
            2425262728291
            2345678

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

            常用鏈接

            留言簿(21)

            隨筆分類

            隨筆檔案

            SDL相關網站

            我的個人網頁

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 492164
            • 排名 - 38

            最新評論

            閱讀排行榜

            評論排行榜

            Windows only. Linux needn't.

            //UVi Soft ( 2008 )
            //Long Fei ( lf426 ), E-mail: zbln426@163.com
            //Laboratory of ZaiBieLiunNian
            //http://www.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://www.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 閱讀(2563) 評論(0)  編輯 收藏 引用 所屬分類: mySDL_GameEngine
            色播久久人人爽人人爽人人片AV| 久久亚洲高清观看| 亚洲国产精品无码久久青草| 无码人妻少妇久久中文字幕| 欧美亚洲色综久久精品国产| 国产福利电影一区二区三区,免费久久久久久久精 | 国产亚洲美女精品久久久久狼| 国产精品久久久天天影视香蕉 | 精品伊人久久久| 国产一区二区三区久久精品| 亚洲午夜精品久久久久久app| 久久男人Av资源网站无码软件 | 国内精品久久久久久99蜜桃| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 久久综合欧美成人| 久久人人爽人人爽人人片AV不| 国产欧美久久一区二区| 日本五月天婷久久网站| 国内精品久久久久久麻豆| 久久亚洲AV成人无码国产| 亚洲国产成人久久精品99 | 久久99国产精品久久99果冻传媒| 国产精品一区二区久久精品涩爱 | 精品熟女少妇AV免费久久| 狠狠综合久久综合中文88| 韩国免费A级毛片久久| 免费久久人人爽人人爽av| 久久久久亚洲AV无码专区网站| 国产国产成人精品久久| 浪潮AV色综合久久天堂| 久久久久久精品无码人妻| 亚洲国产精品无码久久九九| 九九热久久免费视频| 成人a毛片久久免费播放| 欧美亚洲国产精品久久蜜芽| 久久福利青草精品资源站| 国产精品99久久免费观看| 日本精品久久久久中文字幕| 久久香蕉国产线看观看乱码| 国产精品日韩深夜福利久久| 久久久精品久久久久久|