lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi!

Am Mi., 13. Jan. 2021 um 12:30 Uhr schrieb Marcus Mason <m4gicks@gmail.com>:
>
> Hi, as I'm sure the windows users on the list are aware, the lua
> standalone application often struggles with mojibake when printing to
> the windows terminal. To be clear, this is a problem with windows
> consoles specifically, and somewhat ironically using lua from within a
> WSL session leads to no mojibake. The windows function
> SetConsoleOutputCP "Sets the output code page used by the console
> associated with the calling process."  which may be useful in
> correctly printing from lua by selecting the utf8 codepage. Has anyone
> looked into something like this before?

Setting the codepage to 65001 works most of the time, but this is not
a general solution, as output buffering can interfere.

You can try

    fputs( "\xc3\xbc", stdout );

vs.

    putc('\xc3'); putc('\xbc');

See https://stackoverflow.com/questions/45575863/how-to-print-utf-8-strings-to-stdcout-on-windows
or https://stackoverflow.com/questions/1660492/utf-8-output-on-windows-console
for further discussion (ignoring the C++ parts).

In summary: No, UTF-8 is not supported by the windows console.

Regards,
Matthias