Skip to content

Fix lfs.attributes() reporting paths with non-ASCII characters as non-existent on Windows - #666

Open
line0 wants to merge 1 commit into
masterfrom
fix-lfs-attributes-windows-unicode-support
Open

Fix lfs.attributes() reporting paths with non-ASCII characters as non-existent on Windows#666
line0 wants to merge 1 commit into
masterfrom
fix-lfs-attributes-windows-unicode-support

Conversation

@line0

@line0 line0 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

lfs.attributes() reports any path containing a non-ASCII character as nonexistent on Windows, unless the machine is configured for the UTF-8 pseudo-ANSI Code Page (65001). Linux and macOS are not affected.

Unlike every other lfs entry point that takes a path, get_mode() hands the UTF-8 bytes it receives from Lua straight to std::filesystem instead of going through agi::fs::path, causing them to be misinterpreted as whatever encoding is specified by the system ACP.

Beyond lfs.attributes(path, "mode"), the lfs.attributes(path) signature is also affected, as it returns early when get_mode() returns nil.

This surfaced as a DependencyControl error when trying to install packages for Windows users whose account names contain non-ASCII characters: TypesettingTools/Aegisub-Motion#57

Reproduction:

script_name = "lfs.attributes Windows Unicode Bug Repro"
script_description = "lfs.attributes misses directories with non-ASCII characters."

local lfs = require("lfs")

local nonAsciiName = "aegisub-lfs-attributes-bug-repro_Müller"
local function repro()
  local tempDir = aegisub.decode_path("?temp")
  local reproDir = tempDir .. "/" .. nonAsciiName

  lfs.mkdir(reproDir)
  for entry in lfs.dir(tempDir) do
        if entry == nonAsciiName then
      aegisub.log(1, "lfs.dir lists: '%s'\n", entry)
    end
  end
  aegisub.log(1, "lfs.attributes 'mode': %s (Good: directory; Bad: nil)\n", tostring(lfs.attributes(reproDir, "mode")))
  aegisub.log(1, "lfs.attributes 'modification': %s\n", tostring(lfs.attributes(reproDir, "modification")))
  lfs.rmdir(reproDir)
end

aegisub.register_macro(script_name, script_description, repro)

@line0
line0 requested a review from CoffeeFlux August 11, 2026 23:10
@line0 line0 added the bug Something isn't working label Aug 11, 2026
@CoffeeFlux

Copy link
Copy Markdown
Member

Filed https://developercommunity.visualstudio.com/t/C1001-in-msc1cpp:-filesystem::path-deri/11134321 and it should probably be linked in the comment. We'll have to include the workaround until we no longer want to support affected VS versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants