Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++

ASCII strings to Unicode in C++

0.00/5 (No votes)
13 May 2011CPOL 10.1K  
also since _bstr_t's have operator (char *) and operator (wchar_t *) if you have included comutil.h, you can use it to do your conversion.char * source = this is my source ;_bstr_t converter_temp(source) ;wstring target ;target = wstring(converter_temp) ;... and the other way...
also since _bstr_t's have operator (char *) and operator (wchar_t *) if you have included comutil.h, you can use it to do your conversion.

char * source = "this is my source" ;
_bstr_t converter_temp(source) ;
wstring target ;
target = wstring(converter_temp) ;
... and the other way ...

std:string back_To_Mbcs = (char *) _bstr_t(target.c_str()) ;


I just wouldn't do it in a loop because we don't know if the _bstr_t implementation uses A2W() behing the scenes.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)