我想用希伯来语(从右到左)打印到控制台

时间:2017-05-18 15:52:11

标签: c++ visual-studio-2015 console stdout hebrew

与英语和拉丁语不同,希伯来语 - 它的精彩,是从右到左书写的。我不想将此消息传达给计算机领域。

我知道我必须使用unicode / wchar作为实际的字符串。

我知道我必须设置控制台以支持unicode / wchar。

我知道我必须告诉控制台使用支持的字体。

所以我运行这段代码:

#include "stdafx.h" // MS Visual Studio precompiled header file
#include <fcntl.h> // for _setmode
#include <io.h> // for _setmode
#include <windows.h> // for SetCurrentConsoleFontEx
int main()
{
    // use unicode/wchar as the actual string.
    wchar_t *hebrewString = L"עברית";

    // set the console to support unicode/wchar. 
    _setmode(_fileno(stdout), _O_U16TEXT);

    // tell the console to use a supported font.
    CONSOLE_FONT_INFOEX info = { 0 };
    info.cbSize = sizeof(info);
    info.dwFontSize.Y = 20;
    wcscpy_s(info.FaceName, L"Courier New");
    SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL,  &info);

    // print
    wprintf(L"%s", hebrewString);

    // wait for input, so that console won't disappear immediately
    getchar();

    // return
    return 0;
}

这不错,但实际打印相反: enter image description here

有没有办法正确配置它以便以正确的顺序打印,或者我必须在将字符串传递给控制台之前手动翻转它?

0 个答案:

没有答案