converting std::string to std::wstring

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • red floyd

    converting std::string to std::wstring

    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

  • Ron Natalie

    #2
    Re: converting std::string to std::wstring


    "red floyd" <no.spam@here.d ude> wrote in message news:I3ejb.539$ 0g6.117@newssvr 29.news.prodigy .com...[color=blue]
    > 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( )?
    >[/color]
    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.



    Comment

    Working...