luafilesystem icon indicating copy to clipboard operation
luafilesystem copied to clipboard

Does not compile in Windows in Unicode (WCHAR) mode

Open rpatters1 opened this issue 2 years ago • 2 comments

It is easy enough to fix by appending "A" to the affected functions:

  • CreateFileA
  • GetFinalPathNameByHandleA
  • CreateHardLinkA
  • CreateSymbolicLinkA
  • GetFileAttributesExA

However, it really depends on what the goal of the repo is. A more appropriate approach might be to convert all the relevant strings to WCHAR and call the W versions. This would require changing the inputs from ANSI to UTF8.

rpatters1 avatar Oct 27 '23 20:10 rpatters1

See discussion on #57 – changing the lfs API to use UTF-8 would make it incompatible with built-in Lua functionality. For example you wouldn’t be able to pass a file name from an lfs directory listing to io.open.

cuavas avatar Oct 27 '24 08:10 cuavas

If you change the Window API calls to explicitly use the A functions, then the project will build in either MultiByte or Unicode modes but continue to function the same. (That is, it will continue to be compatible with io.open.)

Windows itself now has a UTF8 option for ANSI. I would hope it will gradually move everyone in that direction. That will allow all 8-bit char functions (including Lua's) to run with utf8.

rpatters1 avatar Oct 27 '24 11:10 rpatters1