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

                 來(lái)源: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 閱讀(1636) 評(píng)論(6)  編輯 收藏 引用 所屬分類(lèi): Resource

            評(píng)論

            # re: How to convert string to wstring? 2009-03-27 13:03 陳梓瀚(vczh)

            你試試漢字。  回復(fù)  更多評(píng)論   

            # re: How to convert string to wstring? 2009-03-27 17:56 codejie

            么問(wèn)題。  回復(fù)  更多評(píng)論   

            # re: How to convert string to wstring? 2009-03-27 22:59 陳梓瀚(vczh)

            你如何判斷他沒(méi)事  回復(fù)  更多評(píng)論   

            # re: How to convert string to wstring?[未登錄](méi) 2009-03-29 23:03 codejie

            可以正常讀取一個(gè)中文文件名的MP3文件。你有什么疑問(wèn)嗎?  回復(fù)  更多評(píng)論   

            # re: How to convert string to wstring?[未登錄](méi) 2013-11-26 01:19 煙圈

            int main()
            {
            //string s1 = "";
            //wstring s2 = StringToWString(s1);
            string s1 = WStringToString(L"中國(guó)");

            cout <<s1 <<endl;
            return 0;
            }

            試試肯定不行。。

              回復(fù)  更多評(píng)論   

            # re: How to convert string to wstring? 2013-11-26 09:24 codejie

            @煙圈
            會(huì)不會(huì)是'cout'用的不對(duì)呢?  回復(fù)  更多評(píng)論   

            公告

            Using C++

            導(dǎo)航

            統(tǒng)計(jì)

            留言簿(73)

            隨筆分類(lèi)(513)

            積分與排名

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久r热这里有精品视频| 九九热久久免费视频| 久久久久亚洲av成人网人人软件| 国产精品免费久久久久久久久| 久久国产乱子伦精品免费强| 久久久精品免费国产四虎| 国产91色综合久久免费| 93精91精品国产综合久久香蕉| 色天使久久综合网天天| 久久亚洲综合色一区二区三区| 99久久www免费人成精品| 久久精品国产色蜜蜜麻豆| 久久亚洲AV成人出白浆无码国产| 国产成人无码久久久精品一| 夜夜亚洲天天久久| 亚洲人成网站999久久久综合| 久久久久亚洲AV无码永不| AA级片免费看视频久久| 久久无码专区国产精品发布| AAA级久久久精品无码片| 无码任你躁久久久久久老妇App| 蜜臀av性久久久久蜜臀aⅴ麻豆| 欧美亚洲另类久久综合| 中文字幕久久亚洲一区| 国产精品女同一区二区久久| 7777精品久久久大香线蕉| 91亚洲国产成人久久精品网址 | 伊人久久大香线蕉精品不卡| 香蕉久久夜色精品升级完成| 久久久久久国产a免费观看不卡 | 免费国产99久久久香蕉| 亚洲中文字幕伊人久久无码| 久久国产精品久久久| 久久国产免费观看精品| 久久国产免费观看精品| 久久A级毛片免费观看| 亚洲精品国产美女久久久| 久久妇女高潮几次MBA| 国产香蕉久久精品综合网| 一本久久知道综合久久| 1000部精品久久久久久久久|