convert std::string to std::wstring
Hello, I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples. Thanks Hansjörg
since char is convertible to wchar_t and vice versa (with a possibility for lost precision of course) I usually just do this:
string s("something");
wstring ws(s.begin(), s.end());
You can do the reverse with wstring to string and as long your wstring doesn't contain non-ASCII characters it should be okay.
--- On Wed, 6/18/08, Hansi
The serialization library contains both converters in the form of "Dataflow Iterators" mb_from_wchar and wchar_from_mb. They are built using generic code of boost iterators. Robert Ramey Hansi wrote:
Hello,
I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples.
Thanks Hansjörg
Please elaborate. I also have interest. Thanks Max
The serialization library contains both converters in the form of "Dataflow Iterators" mb_from_wchar and wchar_from_mb. They are built using generic code of boost iterators.
Robert Ramey
Hansi wrote:
Hello,
I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples.
Thanks Hansj�rg
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
look for wchar_from_mb.hpp and mb_from_wchar.hpp in boost/archive/iterators for examples look in libs/serialization/test/test_iterators.hpp Robert Ramey Max wrote:
Please elaborate. I also have interest.
Thanks Max
The serialization library contains both converters in the form of "Dataflow Iterators" mb_from_wchar and wchar_from_mb. They are built using generic code of boost iterators.
Robert Ramey
Hansi wrote:
Hello,
I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples.
Thanks Hansjörg
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hello, Thanks for your information. Cheers Max
look for wchar_from_mb.hpp and mb_from_wchar.hpp in boost/archive/iterators
for examples look in libs/serialization/test/test_iterators.hpp
Robert Ramey
Max wrote:
Please elaborate. I also have interest.
Thanks Max
The serialization library contains both converters in the form of "Dataflow Iterators" mb_from_wchar and wchar_from_mb. They are built using generic code of boost iterators.
Robert Ramey
Hansi wrote:
Hello,
I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples.
Thanks Hansj�rg
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Wed, 18 Jun 2008 21:10:07 +0200, Hansi
I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples.
See mbstowcs() and wcstombs() in <cstdlib> Boris
On Wed, Jun 18, 2008 at 12:10 PM, Hansi
Hello,
I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples.
mbstowcs and wcstombs might help, but they can be a crapshoot so make sure you read their docs before you use them. -- Cory Nelson
On Wed, Jun 18, 2008 at 12:10 PM, Hansi
wrote: Hello,
I have searched a lot in every place what is the best way to convert a string to a wstring (and may be vice versa). But til now I don`t got any results. Can anyone give me an hint what is the best way to do that (also good performance?)? maybe there is something available to do that? may be also with some examples.
mbstowcs and wcstombs might help, but they can be a crapshoot so make sure you read their docs before you use them.
Please elaborate. Thanks Max
participants (6)
-
Boris
-
Cory Nelson
-
Hansi
-
Kamil Zubair
-
Max
-
Robert Ramey