• <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 閱讀(1637) 評論(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)

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久久精品国产Sm最大网站| 久久精品国产亚洲AV嫖农村妇女| 亚洲国产精品久久久久婷婷软件| 久久国产欧美日韩精品| 狠色狠色狠狠色综合久久| 老司机午夜网站国内精品久久久久久久久 | 久久久久中文字幕| 青青久久精品国产免费看| 亚洲成色www久久网站夜月| 久久精品成人免费看| 久久99精品久久久大学生| 久久国产精品久久国产精品| 思思久久好好热精品国产| 久久久久久久综合日本亚洲| 国产精品乱码久久久久久软件| 99久久国语露脸精品国产| 色天使久久综合网天天| 亚洲精品高清久久| 久久av无码专区亚洲av桃花岛| 久久国产成人午夜AV影院| 久久777国产线看观看精品| 国产精品一区二区久久精品涩爱 | 亚洲国产精品无码久久青草| 精品综合久久久久久888蜜芽| 色综合久久天天综线观看| 精品久久久久久无码中文字幕| 久久久久无码精品国产| 人妻无码αv中文字幕久久| 午夜福利91久久福利| 久久精品一区二区三区中文字幕 | 久久亚洲欧美国产精品| 精品一二三区久久aaa片| 久久婷婷国产剧情内射白浆| 久久男人AV资源网站| 久久久久亚洲AV无码专区网站| 久久午夜电影网| 一本色道久久88加勒比—综合| 狠狠色丁香婷婷综合久久来| 久久美女网站免费| 久久99精品国产麻豆蜜芽| 久久无码国产|