65.9K
CodeProject is changing. Read more.
Home

ASCII strings to Unicode in C++

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

May 13, 2011

CPOL
viewsIcon

10133

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.