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

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            精品国产综合区久久久久久| 国产一区二区三区久久精品| 久久综合视频网站| 中文字幕亚洲综合久久菠萝蜜 | 久久精品国产亚洲麻豆| 亚洲欧美国产精品专区久久| 久久久久久久精品妇女99| 久久亚洲AV成人出白浆无码国产| 亚洲综合久久夜AV | 一本色道久久综合亚洲精品| 久久久九九有精品国产| 亚洲性久久久影院| 色综合合久久天天综合绕视看| 日韩精品久久久久久| 九九精品久久久久久噜噜| 国内精品久久久久影院优| 国产成人精品综合久久久| 久久精品国产亚洲AV忘忧草18| 亚洲国产二区三区久久| 午夜精品久久影院蜜桃| 狠狠色丁香婷婷综合久久来| 99精品国产综合久久久久五月天| 91久久成人免费| 久久天天躁狠狠躁夜夜2020一| 精品久久国产一区二区三区香蕉 | 日日狠狠久久偷偷色综合免费| 久久综合九色综合网站| 香蕉99久久国产综合精品宅男自 | 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 亚洲欧洲久久久精品| 国产精品久久久久久久久免费 | 无码人妻久久一区二区三区免费 | 亚洲国产欧洲综合997久久| 国产精品一久久香蕉国产线看 | 久久w5ww成w人免费| 久久久噜噜噜久久| 韩国三级中文字幕hd久久精品| 狠狠色综合久久久久尤物| 精品国产乱码久久久久久郑州公司| 丁香色欲久久久久久综合网| 久久精品国产99国产精品|