lua-users home
lua-l archive

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




On Fri, Feb 25, 2022 at 4:50 PM Egor Skriptunoff <egor.skriptunoff@gmail.com> wrote:

I'd like to have an option to reopen stdin/stdout in binary mode.
It is currently impossible from Lua code.
So, Lua scripts are unable to process and generate binary input/output on Windows.
Other programs (written on C) read/write binary data in stdout/stdin,
but the "lua.exe myscript.lua" process can not be piped to them.

It would be useful for "lua.exe" to have an option to force unbuffered binary standard streams.
It does not matter how many letters it would consist of.

The problem is that there is no portable way of doing this. In Windows (according to MS documentation) you could do something like

int result = _setmode(_fileno(stdin), _O_BINARY);

to set stdin and/or stdout to binary mode.


--