I have similar problem, but with Cyrillic output on several Windows (XP, 7,
10). The best I did was to use low level routine SetOutputConsole to control
the output. You can use GetOutputConsole to save current setting and restore it
on application end. I hope something like this will be useful for you:
module **console.nim**:
# Low-level & OS specific routines
proc getConsoleOutputCP(): cint
{. importc: "GetConsoleOutputCP", stdcall, dynlib: "kernel32" .}
proc setConsoleOutputCP(codepage: cint): cint
{. stdcall, dynlib: "kernel32", importc: "SetConsoleOutputCP",
discardable .}
let originalOutCP = getConsoleOutputCP()
proc setConsole*(codepage: cint = 65001) =
discard setConsoleOutputCP(codepage)
proc restoreConsole* =
discard setConsoleOutputCP(originalOutCP)
Application:
import console
setConsole(936)
echo "你好"
restoreConsole()