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

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久伊人五月丁香狠狠色| 精品久久久久久国产三级| 久久久久亚洲?V成人无码| 国产精品99久久久久久宅男小说| 久久国产午夜精品一区二区三区| 中文字幕无码久久人妻| AV狠狠色丁香婷婷综合久久| 精品99久久aaa一级毛片| 久久久黄色大片| 久久精品亚洲欧美日韩久久| 久久久午夜精品| 久久精品成人免费网站| 亚洲国产精品成人久久| 久久久久无码精品国产app| 伊人久久大香线蕉av不变影院| 欧美激情精品久久久久久| 久久夜色tv网站| 国产午夜免费高清久久影院| 久久国产免费直播| 久久亚洲国产精品一区二区| 国内精品久久久久久久久电影网| 99热都是精品久久久久久| 91久久精品无码一区二区毛片| 久久久一本精品99久久精品66| 亚洲精品无码久久久久久| 久久99精品国产麻豆婷婷| 国产V亚洲V天堂无码久久久| 国产色综合久久无码有码| 久久久久18| 久久久无码精品午夜| 久久精品不卡| 久久艹国产| 久久亚洲av无码精品浪潮| 国产精品VIDEOSSEX久久发布| 久久国产高清字幕中文| 国产高潮国产高潮久久久| 久久不见久久见免费视频7| 国产精品一久久香蕉国产线看观看| 亚洲精品乱码久久久久久蜜桃图片 | 国产精品天天影视久久综合网| 久久亚洲国产欧洲精品一|