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

            Codejie's C++ Space

            Using C++

            How to convert string to wstring?

                 來源:http://www.codeguru.com/forum/archive/index.php/t-193852.html

            The copy() function does not automatically make room for the destination, so you must make sure that you have enough room in the wstring.

            Why not just write a function to 
            do the conversion?

            #include 
            <string>
            #include 
            <algorithm>

            // Prototype for conversion functions
            std::wstring StringToWString(const std::string& s);
            std::
            string WStringToString(const std::wstring& s);

            std::wstring StringToWString(
            const std::string& s)
            {
            std::wstring temp(s.length(),L
            ' ');
            std::copy(s.begin(), s.end(), temp.begin());
            return temp;
            }


            std::
            string WStringToString(const std::wstring& s)
            {
            std::
            string temp(s.length(), ' ');
            std::copy(s.begin(), s.end(), temp.begin());
            return temp;
            }

            using namespace std;

            int main()
            {
            string s1 = "Hello";
            wstring s2 
            = StringToWString(s1);
            s1 
            = WStringToString(s2);
            return 0;
            }

            Regards,

            Paul McKenzie

            posted on 2009-03-27 12:35 codejie 閱讀(1643) 評論(6)  編輯 收藏 引用 所屬分類: Resource

            評論

            # re: How to convert string to wstring? 2009-03-27 13:03 陳梓瀚(vczh)

            你試試漢字。  回復  更多評論   

            # re: How to convert string to wstring? 2009-03-27 17:56 codejie

            么問題。  回復  更多評論   

            # re: How to convert string to wstring? 2009-03-27 22:59 陳梓瀚(vczh)

            你如何判斷他沒事  回復  更多評論   

            # re: How to convert string to wstring?[未登錄] 2009-03-29 23:03 codejie

            可以正常讀取一個中文文件名的MP3文件。你有什么疑問嗎?  回復  更多評論   

            # re: How to convert string to wstring?[未登錄] 2013-11-26 01:19 煙圈

            int main()
            {
            //string s1 = "";
            //wstring s2 = StringToWString(s1);
            string s1 = WStringToString(L"中國");

            cout <<s1 <<endl;
            return 0;
            }

            試試肯定不行。。

              回復  更多評論   

            # re: How to convert string to wstring? 2013-11-26 09:24 codejie

            @煙圈
            會不會是'cout'用的不對呢?  回復  更多評論   

            公告

            Using C++

            導航

            統計

            留言簿(73)

            隨筆分類(513)

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品人成免费| 久久亚洲AV成人出白浆无码国产| 国产产无码乱码精品久久鸭 | 91超碰碰碰碰久久久久久综合| 国产精品久久国产精麻豆99网站| 9999国产精品欧美久久久久久| 亚洲精品久久久www| 婷婷伊人久久大香线蕉AV| 精品久久久久中文字| 伊人久久大香线蕉AV色婷婷色| 国内精品久久久久伊人av| 一本色道久久综合狠狠躁篇| …久久精品99久久香蕉国产| 亚洲日韩欧美一区久久久久我 | 免费观看久久精彩视频| 精品国产日韩久久亚洲| 99久久综合国产精品二区| 亚洲AV无码一区东京热久久| 久久久免费观成人影院| 狠狠色丁香久久综合婷婷| 国内精品久久久久影院网站| 久久国产劲爆AV内射—百度| 久久播电影网| 国产精久久一区二区三区| 人妻无码αv中文字幕久久 | 国产精品99久久不卡| 精品久久无码中文字幕| 亚洲精品蜜桃久久久久久| 久久亚洲精品无码aⅴ大香| 久久99亚洲综合精品首页| 99久久国产综合精品网成人影院| 少妇精品久久久一区二区三区 | 久久久久人妻一区精品果冻| 久久精品国产亚洲av日韩| 色欲久久久天天天综合网精品| 超级97碰碰碰碰久久久久最新| 伊人伊成久久人综合网777| 亚洲欧美一区二区三区久久| 久久亚洲2019中文字幕| 日韩AV毛片精品久久久| 欧美日韩中文字幕久久久不卡|