I want to print in Hebrew (from right to left) to the console

Viewed 1093

Unlike English and Latin languages, Hebrew - in it's awesomeness, is written right to left. I wan't to get this message across to the computer realm.

I understand I have to use unicode/wchar for the actual string.

I understand I have to set the console to support unicode/wchar.

I understand I have to tell the console to use a supported font.

So I run this code:

#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;
}

This isn't bad, but the actual print is in reverse: enter image description here

Is there a way to properly configure it so that it will print in the right order, or do I have to manually flip the string before passing it to the console?

0 Answers
Related