lua-users home
lua-l archive

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


On Tue, Aug 9, 2016 at 12:43 PM, Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
>> I don't know why, but just adding
>>
>>      SetConsoleOutputCP(CP_UTF8);
>>
>> doesn't quite work -- or rather, it works when a new console is
>> opened fresh for Lua (e.g if you double-click lua.exe from Windows
>> Explorer), but fails if you run lua from an existing console (by
>> "fails" I mean that 3 garbage characters are printed instead of the
>> snowman, indicating that the OEM codepage is being used instead
>> of UTF-8).
>
>
> Probably, you have different fonts for different console windows?
> CP_UTF8 does not work if your console window has raster font selected
> (such as "Terminal").
>
> A simple program consisting of four lines:
> oldCP := GetConsoleOutputCP;
> SetConsoleOutputCP(CP_UTF8);
> WriteConsoleA(...);
> SetConsoleOutputCP(oldCP);
> works just fine inside already opened console (tested on WinXP SP3)
> provided the console has true-type-font assigned.

Even disregarding the font, I would consider it to "work" if it
outputs a single box instead of three boxes.

/s/ Adam