none
c++ std::wstring to std::string RRS feed

  • Question

  • Hi.

    I need russian support in std::string.

    How i can convert from std::wstring  = L"Hello world, Привет мир" to std::string whis convert to correct locale.

    Tuesday, October 8, 2013 6:19 PM

Answers

  • Well, my first thought is just make sure you use Unicode everywhere so you don't have to mess with locales and such.

    There probably is a way to do this with C/C++ locales, but if you are targeting Windows, I would just use WideCharToMultibyte to do the conversion and be done with it.

    • Marked as answer by Anna Cc Monday, October 14, 2013 7:55 AM
    Tuesday, October 8, 2013 9:53 PM
  • Hi Mikhail Bfox KS,

    You can consider converting wstring[0] to ASC2 then converting ASC2 to string[0].  


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Anna Cc Monday, October 14, 2013 7:53 AM
    Friday, October 11, 2013 8:23 AM

All replies

  • Well, my first thought is just make sure you use Unicode everywhere so you don't have to mess with locales and such.

    There probably is a way to do this with C/C++ locales, but if you are targeting Windows, I would just use WideCharToMultibyte to do the conversion and be done with it.

    • Marked as answer by Anna Cc Monday, October 14, 2013 7:55 AM
    Tuesday, October 8, 2013 9:53 PM
  • Hi Mikhail Bfox KS,

    You can consider converting wstring[0] to ASC2 then converting ASC2 to string[0].  


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Anna Cc Monday, October 14, 2013 7:53 AM
    Friday, October 11, 2013 8:23 AM