Skip to content

fix(locale): promote LC_CTYPE to UTF-8 for accented paths on bare-locale daemons - #542

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/amuled-utf8-ctype-locale
Jul 21, 2026
Merged

fix(locale): promote LC_CTYPE to UTF-8 for accented paths on bare-locale daemons#542
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/amuled-utf8-ctype-locale

Conversation

@got3nks

@got3nks got3nks commented Jul 21, 2026

Copy link
Copy Markdown

A headless amuled without LANG / LC_* (systemd, Docker) runs under POSIX/C, whose ASCII codeset can't represent accented UTF-8 paths → wxConvFileName fails to open them → an accented shared directory silently becomes invisible to the file scan. Reproduced on ARM64 glibc: LC_ALL=C finds 0 files in Mú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, promote LC_CTYPE to UTF-8 (C.UTF-8, falling back to en_US.UTF-8) and export it, so the promotion survives wx re-resolving the locale from the environment during app init (a plain setlocale() alone gets undone there). It also pins LC_NUMERIC=C in the environment so child processes (media probe, spawned amuleweb/amuleapi) keep C decimal parsing after a C-valued LC_ALL is 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_MESSAGES untouched; and the codebase's explicit LC_CTYPE=C scopes (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.

…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
got3nks force-pushed the fix/amuled-utf8-ctype-locale branch from 252b397 to 4de5e7d Compare July 21, 2026 10:03
@got3nks
got3nks merged commit b026da5 into amule-org:master Jul 21, 2026
13 checks passed
@got3nks
got3nks deleted the fix/amuled-utf8-ctype-locale branch July 21, 2026 10:13
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.

1 participant