Answer the question
In order to leave comments, you need to log in
How to call MultiByteToWideChar?
Hello!
I need to convert text from ASCII to Unicode
To do this, I write:
setlocale(LC_ALL, "Russian");
char* c="фывапр";
int q = CP_ACP;
int b = MultiByteToWideChar(q, 0, c, -1, 0, 0);
wchar_t* o = new wchar_t[b];
MultiByteToWideChar(q, 0, c, -1, o, b);
printf("%s\n", o);
Answer the question
In order to leave comments, you need to log in
So it is probably normal and translates. Only printf does not know how to work with this. Try wprintf instead.
Declare Unicode constants like this:
And output to the console using wprintf, as Vladimir Martyanov wrote
The conversion is most likely correct, if you want to check the result without problems, look in the VisualStudio debugger, but if there are problems, then master the Windows console. Only this perverted way works there:
#include <windows.h>
....
DWORD n;
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"фыва", 4, &n, 0);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question