• <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 閱讀(1645) 評論(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无码免费看大片| 久久综合视频网| 久久人人妻人人爽人人爽| 99国产精品久久久久久久成人热| 激情久久久久久久久久| 国产精品久久久久久久久软件| 97久久天天综合色天天综合色hd| 久久久精品国产Sm最大网站| 一本色道久久HEZYO无码| 国产成人无码精品久久久久免费| 亚洲国产精品无码久久久久久曰| 色8久久人人97超碰香蕉987| 青青青国产精品国产精品久久久久 | 久久精品99久久香蕉国产色戒| 日韩精品久久久久久| 亚洲国产精品无码成人片久久| 久久国产成人午夜aⅴ影院 | 2020最新久久久视精品爱| 综合人妻久久一区二区精品| 97久久精品人人做人人爽| 精品无码久久久久久尤物| 久久久亚洲AV波多野结衣| 精品久久久久中文字| 色综合久久久久网| 国产亚洲欧美成人久久片| 国产成人精品免费久久久久| 久久妇女高潮几次MBA| 久久笫一福利免费导航| 久久婷婷五月综合97色直播| 精品熟女少妇aⅴ免费久久| 精品久久8x国产免费观看| 婷婷伊人久久大香线蕉AV | 久久精品国产一区| 91精品国产综合久久精品| 国产精品女同久久久久电影院| 亚洲熟妇无码另类久久久| 久久久国产打桩机| 亚洲级αV无码毛片久久精品|