Why use MultiByteToWideCharArray to convert std :: string to std :: wstring?

I want to convert std :: string to std :: wstring. There are two approaches that I have encountered.

  • Given the string str, we cannot convert it to a wide string using the following code wstring widestring = std :: wstring (str.begin (), str.end ());

  • Another approach is to use MultiByteToWideCharArray ().

What I wanted to understand was what is the disadvantage of using the first approach and how the second approach solves the issue

+3
source share
2 answers

MultiByteToWideChar offers more options (for example, the ability to select "code pages") and correctly translates non-standard characters.

+4

. (char) . , , .

MultiByteToWideChar , .

+4

Source: https://habr.com/ru/post/1783181/


All Articles