Wprintf with UNICODE characters (Hebrew)

I have a wchar_t array with characters in English and Hebrew, and when I print it with wprintf (), it only prints console English characters. When I use _wsetlocale (LC_ALL, L "Hebrew"), I get Hebrew characters as "????". The machine I work for supports Hebrew, of course.

BTW - using c: \ windows \ system32 \ cmd.exe and 'dir' in the directory with Hebrew characters also displays "???" instead of Hebrew.

Any idea?

+4
source share
2 answers

Have you confirmed that your console font can handle Unicode characters? Most are not. You can try the font Consolas.

When I came across this before, I found this article by Michael Kaplan to be extremely useful.

+2
source

Basically, the Microsoft C runtime library is not well implemented to allow this.

You can do _setmode(_fileno(stdout), _O_U16TEXT); and then write using wcout or wprintf will work. However, an attempt to use cout or printf or anything that does not write UTF-16 will cause the program to crash.

+2
source

Source: https://habr.com/ru/post/1389486/


All Articles