c++中wstring、string、_bstr_t互转

1、从 unicode 字符串转化为 ansi字符串

wstring ws="123";

string s = (char *) _bstr_t ( ws2.c_str() );


2、从 ansi字符串转化为 unicode 字符串

string s="123";

ws1 = ( wchar_t *) ( _bstr_t ( s.c_str( ) ));


3、ansi字符串、unicode 字符串转化成_bstr_t

wstring ws="123";

string s="123";

_bstr_t bstr1=ws.c_str( );

_bstr_t bstr2=s.c_str( );


4、_bstr_t转化ansi字符串、unicode 字符串

_bstr_t bstr=“123”;

string s=(char *) bstr;

wstring ws = ( wchar_t *)bstr;





版权声明:本文为fuck487原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。