0

I need to convert a string to a wchar_t. I have tried a lot of different approaches, but I keep having problems with Cyrillic text. When using wcout to debug, I keep getting wrong output, but when just using Latin characters, no problems arise.

So how can I convert a string containing Cyrillic characters to a wchar_t?

upd: I found the problem, I made a mistake when used wcout to debug, I all time was getting wrong output. But i manually rechecked character codes and it is realy UTF-16. I dont know how to make correct output UTF-16 into console by wcout, but it is not so important for me.

1 Answers1

1

First you also need to know size of wchar_t that that library requires. It may be 16 or 32 bits on different systems. Then you can use std::wstring_convert::from_bytes. This SO answer can also be useful for you.

Community
  • 1
  • 1
mvidelgauz
  • 2,176
  • 1
  • 16
  • 23