• <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浪潮 | 91精品国产91久久| 欧美成a人片免费看久久| 亚洲精品无码久久久久久| 国产精品日韩深夜福利久久| 精品久久久一二三区| 久久国产一区二区| 亚洲精品乱码久久久久久| 国产精品久久久福利| 精品综合久久久久久98| 久久男人中文字幕资源站| 久久99国产乱子伦精品免费| 久久人人爽人人爽人人爽| 久久97久久97精品免视看秋霞| 久久精品国产99久久久| 久久中文字幕人妻丝袜| 色诱久久av| 久久97久久97精品免视看秋霞| 996久久国产精品线观看| 麻豆精品久久久久久久99蜜桃| 久久久久人妻一区精品果冻| 99久久婷婷国产一区二区| 2022年国产精品久久久久| 欧美大香线蕉线伊人久久| 一本色道久久88—综合亚洲精品| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 99久久做夜夜爱天天做精品| 欧美粉嫩小泬久久久久久久 | 2021国产精品午夜久久| 久久久高清免费视频| 亚洲国产成人久久笫一页| 青青久久精品国产免费看| 久久九九青青国产精品| 欧美激情精品久久久久| 国产精自产拍久久久久久蜜| 久久精品成人免费观看97| 一级a性色生活片久久无少妇一级婬片免费放| 伊人久久综在合线亚洲2019|