S
S
sanek20052021-10-27 18:53:32
C++ / C#
sanek2005, 2021-10-27 18:53:32

Why are hieroglyphs displayed instead of Russian in WinAPI?

I want to display a message using a MessageBox. there is Russian. on the box itself, instead of text, hieroglyphs. I heard that this is due to encodings, but I don’t understand what I did wrong, so in addition to the solution, I would like to explain about encodings (that is, in what encoding of the string in the project, which WInAPI uses, how to convert encodings, etc.). p.)
here is the code:

void SendMsg(const wchar_t* msg, const wchar_t* header_text)
{
  MessageBox(nullptr, msg, header_text, MB_OK);
}

int main()
{
    SendMsg(L"текст", L"заголовок");
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
User700, 2021-10-27
@User700

MessageBox can connect as MessageBoxA, requiring a one-byte encoding; or as MessageBoxW for unicode. The L prefix declares a unicode string. When compiling, there are no warnings about type casting? Possibly configured to use MessageBoxA. you can explicitly specify MessageBoxW. Although no, with such an error it would not compile.
Maybe the point is in what encoding the compiler understands the source code file:
https://qna.habr.com/q/525512

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question