Skip to content

UTF-8 paths through the wide Win32 calls - #1

Merged
bycruz merged 1 commit into
lde-org:masterfrom
lasajar:utf8-paths
Nov 6, 2026
Merged

bycruz merged 1 commit into
lde-org:masterfrom
lasajar:utf8-paths

Conversation

@lasajar

@lasajar lasajar commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

So basically the Windows backend simply does not take into consideration of any characters outside lde's current codepage. The issue is though, you can't really set a process' codepage neatly without using an application manifest and that's a fairly wide-scoped change that would need to be done in lde itself.

So to make things simpler, this just manually uses MultiByteToWideChar and WideCharToMultiByte which lets fs choose the codepage to work in per Win32 API call instead of forcing it on the lde process which may have unintended side effects. Again, the true solution would be adding Windows application manifests to lde but that's a far bigger change than this.

The Windows backend used the narrow (A) calls, which read and return names in
the system code page: 'Antônio' came back as the single byte 0xF4, names outside
the code page came back as '?', and fs.watch replaced every non-ASCII character
with '?'. Every path now crosses MultiByteToWideChar/WideCharToMultiByte with
CP_UTF8 and uses the W calls, and junction targets are encoded from the wide
GetFullPathNameW result.

Loading the backend also sets the Universal CRT's LC_CTYPE to .UTF8 so io.open,
os.rename and fopen in native modules accept the same UTF-8 paths.
@bycruz
bycruz merged commit dc764d1 into lde-org:master Nov 6, 2026
5 of 7 checks passed
@bycruz

bycruz commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants