By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

converting std::string to std::wstring

P: n/a
I have a an app that I'm writing which uses char and std::string. I'm using
a library which expects wchar_t arrays.

Is there a standard way to convert between std::string and std::wstring, or do
I need to use something like std::transform()?

Thanks

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"red floyd" <no*****@here.dude> wrote in message news:I3***************@newssvr29.news.prodigy.com. ..
I have a an app that I'm writing which uses char and std::string. I'm using
a library which expects wchar_t arrays.

Is there a standard way to convert between std::string and std::wstring, or do
I need to use something like std::transform()?

Well, there's no real PORTABLE way... it might not even be possible. The whole
concept of the mapping between mb to wc characters is highly implemetnation
dependent. C++ is rather schizoid about whether it's multibyte or wide character
based having a complete implementation of neither.

The best bet is the codecvt C++ class or the mbtowc family of functions in the
C library. All of these work on arrays of characters and not strings, you could
use transform to warp calls to these, but there's no canned function that
does what you want I suspect.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.