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

            積分與排名

            最新評論

            閱讀排行榜

            評論排行榜

            久久66热人妻偷产精品9| 久久青青草原亚洲av无码app| AV无码久久久久不卡网站下载| 久久大香香蕉国产| 久久久久女教师免费一区| 伊人久久成人成综合网222| 久久综合给合久久狠狠狠97色69| 亚洲国产成人久久综合一| 亚洲AV伊人久久青青草原| 国产精品久久午夜夜伦鲁鲁| 久久无码AV中文出轨人妻| 久久久婷婷五月亚洲97号色 | 国产精品久久亚洲不卡动漫| 久久er热视频在这里精品| 无码8090精品久久一区| 久久久久亚洲av无码专区| 久久青青草视频| 99精品久久久久久久婷婷| 国产2021久久精品| 国产午夜免费高清久久影院| 亚洲精品tv久久久久久久久久| 国产精品久久久久影院嫩草 | 久久综合综合久久狠狠狠97色88| 久久天天婷婷五月俺也去| 99久久人人爽亚洲精品美女| A狠狠久久蜜臀婷色中文网| 新狼窝色AV性久久久久久| 久久久精品视频免费观看| 一本一道久久精品综合| 久久综合狠狠综合久久综合88 | 久久免费小视频| 久久精品国产一区| 狠狠色婷婷久久一区二区三区| 国产精品久久久久久久人人看| 色综合久久中文字幕综合网| 久久天天躁狠狠躁夜夜2020老熟妇| 日本三级久久网| 久久久久亚洲AV成人网人人网站 | 成人亚洲欧美久久久久| 久久无码av三级| 久久播电影网|