• <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年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            E-mail:zbln426@163.com QQ:85132383 長(zhǎng)期尋找對(duì)戰(zhàn)略游戲感興趣的合作伙伴。

            常用鏈接

            留言簿(21)

            隨筆分類(lèi)

            隨筆檔案

            SDL相關(guān)網(wǎng)站

            我的個(gè)人網(wǎng)頁(yè)

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 493151
            • 排名 - 39

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            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 閱讀(2571) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): mySDL_GameEngine
            久久亚洲国产成人精品无码区| 2021国内精品久久久久久影院| 99久久人妻无码精品系列| 潮喷大喷水系列无码久久精品| 91精品国产9l久久久久| 精品国产综合区久久久久久| 久久久久亚洲国产| 热久久国产精品| 无码任你躁久久久久久老妇| 亚洲精品乱码久久久久久自慰| 国产精品久久久久aaaa| 亚洲欧洲久久久精品| 蜜臀久久99精品久久久久久小说| 国产精品热久久毛片| 久久精品无码一区二区WWW| 国产精品久久久天天影视| 日韩欧美亚洲国产精品字幕久久久 | 97精品久久天干天天天按摩| 国产成人综合久久久久久| 无码伊人66久久大杳蕉网站谷歌| 国产精品伦理久久久久久| 精品熟女少妇av免费久久| 亚洲第一永久AV网站久久精品男人的天堂AV | 激情综合色综合久久综合| 人妻精品久久无码区| 久久久久国产一级毛片高清板| 久久久av波多野一区二区| 欧美日韩精品久久免费| 久久国产视屏| 国产巨作麻豆欧美亚洲综合久久| 99re久久精品国产首页2020| 三上悠亚久久精品| 国产成人综合久久精品红| 久久一区二区三区99| 久久99精品久久久久久9蜜桃| 久久久精品人妻一区二区三区蜜桃| 一97日本道伊人久久综合影院| 精品国产婷婷久久久| 久久免费视频一区| 日日狠狠久久偷偷色综合0| 久久激情亚洲精品无码?V|