Yesterday I spend sometimes to help one of my teammate with a piece of code he wrote to convert a std::string into a std::wstring. At the beginning it seems to be a complex issue for him and he used a complex C based code managing wchar buffer convert char to wchar with mbstowcs.
But finally as often the STL provide everything we need to convert one string type into the other and it’s quite simple.
I quickly use Ideone to demonstrate how to deal with:
As you see we can just use the iterator (old-style or new style like below)
wstring ws(s.begin(), s.end()); or wstring ws(begin(s), end(s));
Aucun commentaire :
Enregistrer un commentaire