• <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>

            看到有前輩寫(xiě)了一個(gè)UTF-8與UNICODE相互轉(zhuǎn)換的代碼,順便提一下,希望可以給大家提供一點(diǎn)幫助.
            下面是一些編碼格式的bit長(zhǎng)

            Examples of fixed-width encoding forms:

            Type Each character
            encoded as
            Notes
              7-bit a single 7-bit quantity example: ISO 646
              8-bit G0/G1 a single 8-bit quantity with constraints on use of C0 and C1 spaces
              8-bit a single 8-bit quantity with no constraints on use of C1 space
              8-bit EBCDIC a single 8-bit quantity with the EBCDIC conventions rather than ASCII conventions
            16-bit (UCS-2) a single 16-bit quantity within a code space of 0..FFFF
            32-bit (UCS-4) a single 32-bit quantity within a code space 0..7FFFFFFF
            32-bit (UTF-32) a single 32-bit quantity within a code space of 0..10FFFF
            16-bit DBCS process code a single 16-bit quantity example: UNIX widechar implementations of Asian CCS's
            32-bit DBCS process code a single 32-bit quantity example: UNIX widechar implementations of Asian CCS's
            DBCS Host two 8-bit quantities following IBM host conventions

            Examples of variable-width encoding forms:

            Name Characters are encoded as Notes
            UTF-8 a mix of one to four 8-bit code units in Unicode
            and one to six code units in 10646
            used only with Unicode/10646
            UTF-16 a mix of one to two 16 bit code units used only with Unicode/10646

            Boost中提供了一個(gè)UTF-8 Codecvt Facet,可以在utf8和UCS-4(Unicode-32)之間轉(zhuǎn)換.
            使用方式如下

              //...
              // My encoding type
              typedef wchar_t ucs4_t;

              std::locale old_locale;
              std::locale utf8_locale(old_locale,new utf8_codecvt_facet<ucs4_t>);

              // Set a New global locale
              std::locale::global(utf8_locale);

              //  UCS-4 轉(zhuǎn)換為 UTF-8
              {
                std::wofstream ofs("data.ucd");
                ofs.imbue(utf8_locale);
                std::copy(ucs4_data.begin(),ucs4_data.end(),
                      std::ostream_iterator<ucs4_t,ucs4_t>(ofs));
              }

              // 讀入 UTF-8 ,轉(zhuǎn)換為 UCS-4 
              std::vector<ucs4_t> from_file;
              {
                std::wifstream ifs("data.ucd");
                ifs.imbue(utf8_locale);
                ucs4_t item = 0;
                while (ifs >> item) from_file.push_back(item);
              }
              //...
            UTF-8 Codecvt Facet詳見(jiàn)
            http://www.boost.org/libs/serialization/doc/codecvt.html

            posted on 2006-02-15 17:19 張沈鵬 閱讀(2667) 評(píng)論(2)  編輯 收藏 引用
            Comments

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


             
            97视频久久久| 热99re久久国超精品首页| 久久久久一本毛久久久| 亚洲精品NV久久久久久久久久 | 久久天天躁狠狠躁夜夜avapp| 欧美与黑人午夜性猛交久久久| 久久久无码精品亚洲日韩蜜臀浪潮 | 久久久久亚洲AV成人片 | 久久久久无码专区亚洲av| 波多野结衣AV无码久久一区| 久久国产一区二区| 久久久久青草线蕉综合超碰| 久久精品国产99久久无毒不卡| 久久精品国产99国产精品| 久久精品欧美日韩精品| 久久久久久av无码免费看大片 | 国产99久久精品一区二区| 亚洲国产小视频精品久久久三级| av国内精品久久久久影院| 久久精品无码一区二区日韩AV| 亚洲精品无码久久久久久| 久久婷婷五月综合色99啪ak| 99久久超碰中文字幕伊人| 亚洲人AV永久一区二区三区久久| 91精品国产9l久久久久| 97久久婷婷五月综合色d啪蜜芽| 国产精品久久久99| 色综合久久中文色婷婷| 精品久久久久久久久午夜福利| 久久久久久国产精品无码下载 | 久久久综合九色合综国产| 久久久免费精品re6| 亚洲AV日韩AV天堂久久| 久久这里都是精品| 久久人人爽人人人人片av| 国内精品久久久久影院老司| 欧美粉嫩小泬久久久久久久| 开心久久婷婷综合中文字幕| 午夜视频久久久久一区 | 奇米影视7777久久精品人人爽| 狠狠色丁香久久婷婷综合图片|