• <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综合合色蜜桃网| 久久精品中文字幕无码绿巨人| 亚洲第一极品精品无码久久| 久久久SS麻豆欧美国产日韩| 久久婷婷五月综合97色| 久久无码av三级| 午夜视频久久久久一区| 精品久久久久香蕉网| 国产精品无码久久综合网| 欧美亚洲国产精品久久| 久久精品亚洲日本波多野结衣| 国产三级精品久久| 中文字幕人妻色偷偷久久| 婷婷综合久久狠狠色99h| 性高湖久久久久久久久AAAAA| 精品人妻久久久久久888| 久久无码AV中文出轨人妻| 国产精品女同久久久久电影院| 久久国产综合精品五月天| 狠狠干狠狠久久| 色偷偷88888欧美精品久久久| 久久天天躁狠狠躁夜夜av浪潮 | 亚洲AV无码1区2区久久| 久久毛片免费看一区二区三区| 国产精品久久成人影院| 精产国品久久一二三产区区别| 国产亚洲精午夜久久久久久| 久久精品嫩草影院| 国产精品女同久久久久电影院| 无码AV中文字幕久久专区| 2021国产精品午夜久久| 无夜精品久久久久久| 久久亚洲精品无码观看不卡| 国产精品综合久久第一页| 青青青青久久精品国产h| 国产精品99久久精品| 国产精品久久久久久福利69堂| 久久久久人妻精品一区二区三区| 综合人妻久久一区二区精品| 亚洲va久久久噜噜噜久久|