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

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品aⅴ无码中文字字幕重口| 久久最近最新中文字幕大全| 一本一道久久a久久精品综合 | 久久免费高清视频| 国产亚州精品女人久久久久久 | 亚洲国产日韩欧美综合久久| 伊人久久久AV老熟妇色| 久久精品国产99国产精品澳门| 久久久久18| 久久精品国产99国产精品澳门| 欧美激情一区二区久久久| 日韩欧美亚洲综合久久影院d3| 日本WV一本一道久久香蕉| 777久久精品一区二区三区无码 | 亚洲一本综合久久| 久久精品青青草原伊人| 亚洲一本综合久久| 国产精品99久久免费观看| 97精品伊人久久大香线蕉| 精品多毛少妇人妻AV免费久久| 国产精品无码久久久久久| 国产精品久久久久久久久软件| 99久久国产综合精品五月天喷水| 久久亚洲美女精品国产精品| 久久久久久久久66精品片| 久久久黄片| 久久精品国产只有精品66| 久久精品国产精品青草app| 国产亚洲综合久久系列| 少妇人妻88久久中文字幕| 久久久久久久精品成人热色戒| 99久久免费国产精品特黄| 久久久久久免费视频| 久久久精品国产免大香伊| 要久久爱在线免费观看| 色99久久久久高潮综合影院| 久久精品国产亚洲Aⅴ香蕉| 久久播电影网| 久久国产精品无| 日产精品久久久久久久| 熟妇人妻久久中文字幕|