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

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久伊人精品青青草原高清| 久久久免费精品re6| 久久久久九国产精品| 色欲综合久久躁天天躁| 一本色道久久88—综合亚洲精品| 欧美噜噜久久久XXX| 99久久亚洲综合精品成人| 日本欧美国产精品第一页久久| 蜜桃麻豆WWW久久囤产精品| 国内精品久久久久影院一蜜桃| 国产午夜精品理论片久久| 少妇熟女久久综合网色欲| 情人伊人久久综合亚洲| 久久99久久99精品免视看动漫 | 久久免费线看线看| 亚洲精品tv久久久久| 久久综合久久久| 狼狼综合久久久久综合网| 亚洲日本久久久午夜精品| 欧美亚洲国产精品久久蜜芽 | 久久久久青草线蕉综合超碰| 久久成人影院精品777| 亚洲AV无码一区东京热久久| 久久亚洲国产精品123区| 伊人色综合久久| 久久综合丝袜日本网| a级成人毛片久久| 国产精品久久国产精麻豆99网站| 中文成人无码精品久久久不卡| 精品久久香蕉国产线看观看亚洲 | 亚洲中文字幕无码一久久区| 狠狠人妻久久久久久综合| 国产麻豆精品久久一二三| 性高湖久久久久久久久| 久久人人爽人人爽人人片AV高清 | 色天使久久综合网天天| 国产精品熟女福利久久AV| 99久久综合国产精品二区| 99久久国产综合精品成人影院| 99久久人人爽亚洲精品美女| 国产精品gz久久久|