• <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) 評(píng)論(6)  編輯 收藏 引用 所屬分類: 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

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

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

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

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

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

            # re: How to convert string to wstring?[未登錄] 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)

            隨筆分類(513)

            積分與排名

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            国产精品激情综合久久| 久久免费精品一区二区| 国产无套内射久久久国产| 国产午夜精品久久久久免费视| 久久99国产精品二区不卡| 久久精品成人欧美大片| 亚洲精品tv久久久久久久久| 久久精品一区二区| 久久AAAA片一区二区| 久久综合给合久久狠狠狠97色 | 日日噜噜夜夜狠狠久久丁香五月| 久久久久亚洲av无码专区导航| 欧美一级久久久久久久大| 99热成人精品热久久669| 麻豆精品久久久久久久99蜜桃| 色综合久久最新中文字幕| 尹人香蕉久久99天天拍| 精品99久久aaa一级毛片| 久久WWW免费人成一看片| 久久综合九色综合欧美就去吻| 国产99久久九九精品无码| 久久久亚洲欧洲日产国码是AV| 国产2021久久精品| 亚洲AV无一区二区三区久久 | 久久精品国产黑森林| 久久精品水蜜桃av综合天堂| 亚洲人成网站999久久久综合 | 69SEX久久精品国产麻豆| 亚洲国产成人精品久久久国产成人一区二区三区综 | 日韩AV无码久久一区二区 | 久久久91精品国产一区二区三区| 日日狠狠久久偷偷色综合96蜜桃| 狠狠色噜噜狠狠狠狠狠色综合久久| 久久久久亚洲AV片无码下载蜜桃| 久久精品亚洲欧美日韩久久| 久久91综合国产91久久精品| 久久午夜伦鲁片免费无码| 伊人久久久AV老熟妇色| 国产人久久人人人人爽| 久久这里只有精品18| 久久久久久午夜成人影院|