lua-users home
lua-l archive

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


On Thu, Jan 17, 2019 at 10:50 PM Egor Skriptunoff <egor.skriptunoff@gmail.com> wrote:
Hi!

If you are creating portable Lua script (Linux/Windows/MacOS)
then you have a problem: standard Lua functions such as "io.open"
expect a filename encoded in UTF-8 on all "normal OS",
but on Windows a filename must be in some Windows-specific encoding
depending on the locale.

There is a pure Lua solution to this problem.

There is no pure Lua solution to this problem.

You are aware of this fact and you mentioned a further constraint in your code:

-- Please note that filenames must contain only symbols from your Windows ANSI codepage (which depends on OS locale).
-- Unfortunatelly, it's impossible to work with a file having arbitrary UTF-8 symbols in its name.

Practically, if your code page is Cyrillic, you cannot specify a file with a Chinese name even though the file exists [1].

One would have to use the Windows API accepting UTF-16 strings, but that is impossible in a pure Lua library.

Cheers,
V.

[1] I am not sure if any current Windows versions support UTF-8 as a system code page. If that were possible, that would invalidate my statement.