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

            看到有前輩寫了一個UTF-8與UNICODE相互轉換的代碼,順便提一下,希望可以給大家提供一點幫助.
            下面是一些編碼格式的bit長

            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中提供了一個UTF-8 Codecvt Facet,可以在utf8和UCS-4(Unicode-32)之間轉換.
            使用方式如下

              //...
              // 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 轉換為 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 ,轉換為 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詳見
            http://www.boost.org/libs/serialization/doc/codecvt.html

            posted on 2006-02-15 17:19 張沈鵬 閱讀(2667) 評論(2)  編輯 收藏 引用
            Comments
            • # re: Boost:UTF-8 Codecvt Facet(unicode 和 utf-8 之間相互轉碼)
              無名高手
              Posted @ 2006-02-24 14:18
              無知少年,看你好學,指點你一下吧

              Unicode Technical Report #17 Character Encoding Mode
              http://www.unicode.org/unicode/reports/tr17

              至于更高層次(更簡單)的要訣,呵呵,不告訴你~~  回復  更多評論   
            • # re: Boost:UTF-8 Codecvt Facet(unicode 和 utf-8 之間相互轉碼)
              張沈鵬
              Posted @ 2006-02-25 10:01
              至于更高層次(更簡單)的要訣是什么?望高手指教,謝謝  回復  更多評論   
             
            久久久无码精品午夜| 99精品久久久久久久婷婷| 色婷婷狠狠久久综合五月| 久久久久国产一级毛片高清板| 久久国内免费视频| 久久久女人与动物群交毛片 | 久久电影网2021| 国产一区二区三区久久| 久久亚洲电影| 久久亚洲AV成人出白浆无码国产| 91精品国产综合久久四虎久久无码一级 | 久久99热国产这有精品| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 亚洲国产日韩综合久久精品| 男女久久久国产一区二区三区| 精品久久国产一区二区三区香蕉| 国色天香久久久久久久小说| 精品久久久久久久久久中文字幕| 色偷偷久久一区二区三区| 久久天天日天天操综合伊人av| 久久午夜伦鲁片免费无码| 久久久久久久久66精品片| 久久精品国产影库免费看 | 久久精品一区二区三区中文字幕| 麻豆成人久久精品二区三区免费| 亚洲中文字幕伊人久久无码 | 久久天天躁夜夜躁狠狠躁2022| 超级碰久久免费公开视频| 久久99精品国产99久久6男男| 无码国内精品久久人妻蜜桃| 思思久久99热只有频精品66| 久久青青草原亚洲av无码| 国内精品久久久久久不卡影院| 久久精品国产亚洲网站| 国内精品久久久久久野外| 国产精品久久国产精麻豆99网站| 亚洲综合精品香蕉久久网| 久久亚洲中文字幕精品有坂深雪 | 久久精品无码专区免费| 亚洲欧洲中文日韩久久AV乱码| 久久久精品日本一区二区三区|