• <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://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) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): mySDL_GameEngine
            亚洲精品午夜国产va久久| 精品久久久久中文字| 国产精品久久成人影院| 777米奇久久最新地址| 国产精品综合久久第一页| 欧美精品丝袜久久久中文字幕| 久久九九久精品国产免费直播| 久久青青草原精品国产| 无码任你躁久久久久久| 久久91精品国产91久久户| 亚洲性久久久影院| 国产精品99久久久久久猫咪| 久久人人爽人人爽人人片av高请| 久久免费视频一区| 99久久精品免费看国产免费| 亚洲国产精品成人久久| 青春久久| 日韩亚洲国产综合久久久| 久久不射电影网| 久久综合给合久久狠狠狠97色69| 亚洲?V乱码久久精品蜜桃| 久久成人影院精品777| 少妇高潮惨叫久久久久久| 97久久婷婷五月综合色d啪蜜芽| 三级片免费观看久久| 久久精品国产欧美日韩| 香蕉久久夜色精品国产小说| 久久99国产乱子伦精品免费| 午夜欧美精品久久久久久久| 成人久久免费网站| 久久久www免费人成精品| 欧美亚洲国产精品久久| 伊色综合久久之综合久久| 亚洲精品无码久久毛片| 日韩精品无码久久一区二区三| 久久综合狠狠综合久久97色| 久久久精品人妻无码专区不卡| 久久久久亚洲av毛片大| 久久亚洲AV成人无码软件| 99久久精品免费看国产一区二区三区| 九九精品久久久久久噜噜|