码迷,mamicode.com
首页 > 编程语言 > 详细

C++ string

时间:2014-09-18 22:16:04      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   div   art   

strings

http://msdn.microsoft.com/en-us/library/ms174288.aspx

 

Example

UTF16 to UTF8 to UTF16 simple CString based conversion

http://www.codeproject.com/Articles/26134/UTF-to-UTF-to-UTF-simple-CString-based-conver

 

wstring => char*

char* = > wstring

bubuko.com,布布扣
int _tmain(int argc, _TCHAR* argv[])
{
    /*char sText[20] = { "多字节字符串!OK!" };  //bug; it is bytes

    DWORD dwNum = MultiByteToWideChar(CP_UTF8, 0, sText, -1, NULL, 0);

    wchar_t* pwText;
    pwText = new wchar_t[dwNum];

    MultiByteToWideChar(CP_UTF8, 0, sText, -1, pwText, dwNum);*/

    wchar_t wText[20] = { L"宽字符转换实例!OK!" };

    DWORD dwNum2 = WideCharToMultiByte(CP_UTF8, NULL, wText, -1, NULL, 0, NULL, FALSE);
    char* psText;
    psText = new char[dwNum2];

    WideCharToMultiByte(CP_UTF8, NULL, wText, -1, psText, dwNum2, NULL, FALSE);


    DWORD dwNum = MultiByteToWideChar(CP_UTF8, 0, psText, -1, NULL, 0);

    wchar_t* pwText;
    pwText = new wchar_t[dwNum];

    MultiByteToWideChar(CP_UTF8, 0, psText, -1, pwText, dwNum);





    return 0;
}
View Code

 

C++ string

标签:style   blog   http   color   io   os   ar   div   art   

原文地址:http://www.cnblogs.com/kevinygq/p/3980064.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!