cp1251:从 char* 转换为 wchar_t* 时编码失真

cp1251: encoding distortion when converting from char* to wchar_t*

我有一个俄语字符串,以 cp1251 编码存储在 cpp 源文件中。

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    const char *src = "Мой текст";
    wchar_t dst[30];

    switch (message)
    {
    case WM_CREATE:
        mbstowcs(dst, src, 29);
        //outputs "Ìîé òåêñò" instead of "Мой текст"
        MessageBox(hWnd, dst, L"Header", MB_OK);    
    ...

不幸的是,“Мой текст”被扭曲了。在这种情况下似乎不应该使用 mbstowcs,但我应该使用什么?

在 WinMain 中尝试 std::setlocale(LC_ALL, "ru_RU.cp1251");,但没有帮助。

根据 Microsoft's documentation, the format of the locale string is language[_country_region[.code_page]] where code_page is the number of the code page without "cp". The table of supported languages and countries 列表 "Russian" 和 "Russia",因此 setlocale 的正确字符串是 "Russian_Russia.1251"