• <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 閱讀(1636) 評論(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)

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            欧美黑人激情性久久| 色综合久久精品中文字幕首页| 狠狠色综合久久久久尤物| 国产精品伊人久久伊人电影| 色婷婷久久久SWAG精品| 无码久久精品国产亚洲Av影片| 久久久无码人妻精品无码| 99久久综合国产精品二区| 久久久久青草线蕉综合超碰| 久久99精品国产麻豆| 欧美精品丝袜久久久中文字幕| 狠狠色噜噜色狠狠狠综合久久| 精品999久久久久久中文字幕| 欧洲性大片xxxxx久久久| 久久综合给久久狠狠97色| 精品综合久久久久久88小说| 亚洲va中文字幕无码久久| 国产成人精品综合久久久| 久久久久99精品成人片直播| 性做久久久久久久久浪潮| 欧美亚洲另类久久综合| 久久99精品国产麻豆宅宅| 久久久无码精品亚洲日韩软件| 久久久久成人精品无码中文字幕| 亚洲精品久久久www| 国产成人无码精品久久久免费| 久久久精品2019免费观看| 一本色道久久综合狠狠躁| 色偷偷88欧美精品久久久| 91精品国产91久久| AV色综合久久天堂AV色综合在| 精品伊人久久久| 亚洲国产精品成人久久蜜臀| 久久久久亚洲AV成人网| 亚洲国产成人久久精品动漫| 国产精品久久精品| 久久婷婷久久一区二区三区| 韩国三级大全久久网站| 色综合久久久久网| 久久久久一本毛久久久| 免费精品久久天干天干|