My end goal here is to write some non-latin text output to console in Windows via a C++ program.
cmd.exe gets me nowhere, so I got the latest, shiny version of PowerShell (that supports unicode). I've verified that I can
- type-in non-unicode characters and
- see non-unicode console output from windows commands (like "dir")
for example, I have this file, "가.txt" (가 is the first letter in the korean alphabet) and I can get an output like this:
PS P:\reference\unicode> dir .\가.txt
Directory: P:\reference\unicode
Mode LastWriteTime Length
Name
---- ------------- ------
----
-a--- 1/12/2010 8:54 AM 0 가.txt
So far so good. But writing to console using a C++ program doesn't work.
int main()
{
wchar_t text[] = {0xAC00, 0}; // 가 has code point U+AC00 in unicode
wprintf(L"%s", text); // this prints a single question mark: "?"
}
I don't know what I'm missing. The fact that I can type-in and see 가 on the console seems to indicate that I have the three needed pieces (unicode support, font and glyph), but I must be mistaken.
I've also tried "chcp" without any luck. Am I doing something wrong in my C++ program?
Thanks!