Click here to Skip to main content
15,888,315 members
Articles / Programming Languages / C++
Alternative
Tip/Trick

ASCII strings to Unicode in C++

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
13 May 2011CPOL 9.8K   1   1
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)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThat's fine - just be aware that it solves a slightly differ... Pin
Nemanja Trifunovic13-May-11 2:31
Nemanja Trifunovic13-May-11 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.