首页 > 代码库 > C++ string

C++ string

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

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