wprintf with UNICODE (Hebrew) characters
Asked Answered
S

2

6

I have a wchar_t array with English and Hebrew characters and when I print it with wprintf() it prints to console the English characters only. When I'm using _wsetlocale( LC_ALL, L"Hebrew" ) I get the Hebrew characters as "????". The machine I'm working on supports Hebrew of course.

BTW - using c:\windows\system32\cmd.exe and 'dir' on a directory with Hebrew characters, also shows "???" instead of Hebrew.

Any idea?

Semang answered 5/1, 2012 at 15:1 Comment(1)
possible duplicate of C++: output contents of a Unicode file to console in WindowsGensler
S
2

Have you confirmed that your console font can handle unicode characters? Most don't. You might try the Consolas font.

When I've run into this before, I've found this article by Michael Kaplan to be extremely helpful.

Sudduth answered 5/1, 2012 at 15:31 Comment(0)
R
2

Basically Microsoft's C runtime library isn't implemented very well to allow this.

You can do _setmode(_fileno(stdout), _O_U16TEXT); and then writing with wcout or wprintf will work. However trying to use cout or printf, or anything that doesn't write UTF-16 will then cause the program to crash.

Riccio answered 6/1, 2012 at 0:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.