lua-users home
lua-l archive

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


Perhaps I should clarify my intent here. I want lua to print correctly on windows, like all the other programming language binaries I use on my computer. Chez scheme, various _javascript_ envrionments, clojure, etc have no issues printing for me. Why is lua.exe not able to do it?

On Wed, Jan 13, 2021, 12:22 Matthias Kluwe <mkluwe@gmail.com> wrote:
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