• <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年3月>
            2425262728291
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

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

            常用鏈接

            留言簿(21)

            隨筆分類

            隨筆檔案

            SDL相關網站

            我的個人網頁

            我的小游戲

            資源下載

            搜索

            •  

            積分與排名

            • 積分 - 492144
            • 排名 - 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中文出轨人妻| 91久久精品91久久性色| 色婷婷久久综合中文久久一本| 久久99精品九九九久久婷婷| 久久亚洲精品国产亚洲老地址| 性高湖久久久久久久久| 青青青国产精品国产精品久久久久| 超级碰久久免费公开视频| 少妇无套内谢久久久久| 超级碰久久免费公开视频| 99久久99久久精品国产片果冻| 久久九九亚洲精品| 亚洲AV日韩精品久久久久久| 青春久久| 久久久无码精品亚洲日韩软件| 97r久久精品国产99国产精| 亚洲v国产v天堂a无码久久| 色噜噜狠狠先锋影音久久| 久久久久久精品无码人妻| 久久久久亚洲AV无码专区网站| AV色综合久久天堂AV色综合在| 久久综合色老色| 久久夜色撩人精品国产小说| 久久天堂电影网| 久久久精品一区二区三区| 久久人妻少妇嫩草AV无码专区| 精品久久久久久久久免费影院| 超级碰久久免费公开视频| 久久国产精品-久久精品| 99久久中文字幕| 久久精品麻豆日日躁夜夜躁| 亚洲AV无码一区东京热久久| 狠狠色丁香婷婷久久综合五月| 欧美午夜A∨大片久久 | 偷偷做久久久久网站| 欧美日韩中文字幕久久久不卡| 久久精品国产WWW456C0M| 国内精品欧美久久精品| 欧美成a人片免费看久久| 色婷婷久久综合中文久久一本| 伊人伊成久久人综合网777|