On Thu, Jan 17, 2019 at 10:50 PM Egor Skriptunoff wrote:
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).
-- Unfortunately, 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.
From the perfectionism point of view, you're correct :-)
But in practice, most use cases are covered by my module.
For example, on all my computers there are no files containing Chinese characters in its filenames.
Assuming you are not speaking Chinese, I want to ask you, do you have such filenames on your machines? ;-)
My module allows a user to use its native language in filenames ON HIS OWN COMPUTER.
But it's not a good idea to have, for example, Chinese filenames on a computer where user don't speak Chinese.
Although it's technically possible in all modern OS, it's inconvenient for the user.
User should be able to understand the meaning of a filename.
(If a filename is not supposed to be human-understandable, it would be better consisted of digits/hexadecimals/GUIDs/etc. instead of human language words)
P.S. Sorry, I wasn't honest enough.
It appears that I do have some filenames containing non-Cyrillic symbols on my computer.
But anyway, such files shouldn't be considered seriously as they all are inside "porn" folder :-)