How are you writing to the log? If it is printf
, I suggest switching to wprintf
, and make sure your keyboard input is being read into a wchar_t. Then you can use %lc
to print out your character.
The only slight catch, is that some Chinese characters don't even fit in a single wchar_t
(the ones at Unicode characters U+10000 and above). For those, you will have to read into a wchar_t
array (or a std::wstring
) and print with %ls
.
Note: The standard doesn't actually specify how big a wchar_t
is, and on Unix platforms, it is common for wchar_t
to be 32-bits, so it can hold any single Unicode code-point as a single UTC-4 value. Windows-NT was developed before it became apparent that 65536 characters wasn't enough, so the API took UTC-2 characters. When Unicode was expanded to a million characters, it would have been too disruptive to change the size of the characters accepted by the API, so they were converted to accept UTF-16. For interfacing with those APIs, wchar_t
on Windows platforms is usually a UTF-16 value.
Of course, even if wchar_t
is big enough for a code point, that doesn't help when a "character" takes more than one code point. For example U+005A LATIN CAPITAL LETTER Z & U+0303 COMBINING TILDE == Z̃ (I don't know if there's a language which uses that as a character, but there doesn't appear to be a combined form for it.)