fix(locale): promote LC_CTYPE to UTF-8 for accented paths on bare-locale daemons - #542
Merged
Merged
Conversation
…ale daemons A headless amuled started without LANG / LC_* (systemd, Docker) runs under the POSIX/C locale, whose ASCII codeset cannot represent accented or other non-ASCII UTF-8 filesystem paths. wxConvFileName then fails to open them, so an accented shared directory silently becomes invisible to the file scan — reproduced on glibc: `LC_ALL=C` finds 0 files in an accented share where a UTF-8 locale finds them. This newly bites the remote shared-folder config (amule-project#530), whose whole point is configuring a headless core, but it affects all of amuled's non-ASCII file handling. aMuleInitLocale() now promotes LC_CTYPE to UTF-8 (C.UTF-8, falling back to en_US.UTF-8) when the resolved codeset is bare ASCII, and exports it so the promotion survives wx re-resolving the locale from the environment during app init — a plain setlocale() alone is undone there. The guard is the codeset itself, so a deliberate UTF-8 or latin1 locale is never overridden, and musl (already UTF-8 in its C locale) never triggers it. Windows is exempt (wide-char filesystem APIs). Verified on an ARM64 glibc VM: with the fix an accented shared folder is found under a bare environment, an explicit `LC_ALL=C`, and healthy UTF-8 locales alike, with no change for a real locale (it_IT.UTF-8).
got3nks
force-pushed
the
fix/amuled-utf8-ctype-locale
branch
from
July 21, 2026 10:03
252b397 to
4de5e7d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A headless amuled without
LANG/LC_*(systemd, Docker) runs under POSIX/C, whose ASCII codeset can't represent accented UTF-8 paths →wxConvFileNamefails to open them → an accented shared directory silently becomes invisible to the file scan. Reproduced on ARM64 glibc:LC_ALL=Cfinds 0 files inMúsica/where a UTF-8 locale finds them. Exposed by the remote shared-folder config (#530, which is all about configuring a headless core), but it affects all of amuled's non-ASCII file handling — same root as #40.Fix — in the shared
aMuleInitLocale(): when the resolved codeset is bare ASCII, promoteLC_CTYPEto UTF-8 (C.UTF-8, falling back toen_US.UTF-8) and export it, so the promotion survives wx re-resolving the locale from the environment during app init (a plainsetlocale()alone gets undone there). It also pinsLC_NUMERIC=Cin the environment so child processes (media probe, spawned amuleweb/amuleapi) keep C decimal parsing after a C-valuedLC_ALLis dropped.Bounded blast radius: the whole block is a no-op unless the process is already in a C/POSIX locale — a deliberate UTF-8 or latin1 locale never reports ASCII, and musl (already UTF-8 in its C locale) never triggers it. Windows is exempt (wide-char filesystem APIs). It runs once at init (thread-safe); degrades gracefully to a no-op if no UTF-8 locale exists; leaves
LC_MESSAGESuntouched; and the codebase's explicitLC_CTYPE=Cscopes (UPnP, wxFileConfig) self-restore and are unaffected.Verified on real Linux with the built binary — the accented folder is found under a bare environment, an explicit
LC_ALL=C, and healthy UTF-8 locales alike, with no change for a real locale (it_IT.UTF-8). clang-format v18 and clang-tidy Tier-1 + Tier-2 clean.