Skip to content

fix(amuled): force UTF-8 file-name conversion on macOS - #318

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/amuled-macos-utf8-filenames
Jul 6, 2026
Merged

fix(amuled): force UTF-8 file-name conversion on macOS#318
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/amuled-macos-utf8-filenames

Conversation

@got3nks

@got3nks got3nks commented Jul 5, 2026

Copy link
Copy Markdown

Symptom

On macOS, headless amuled leaves any finished download whose name contains a non-ASCII character (e.g. ª, ñ, é) stuck in PS_ERROR — it never moves from Temp/ to Incoming/. ASCII-named downloads complete fine, and the monolithic GUI is unaffected. The log shows:

CFile: Error when opening file (…/Incoming/…2ª….mkv): Illegal byte sequence
Unexpected error while completing … File paused

"Illegal byte sequence" is EILSEQ from open().

Root cause

amuled installs its own wxConvFileName at startup, derived from wxLocale::GetSystemEncodingName():

encName = wxLocale::GetSystemEncodingName().Upper();
...
static wxConvBrokenFileNames fileconv(encName);
wxConvFileName = &fileconv;

On macOS that function returns "WESTERN (MAC OS ROMAN)" regardless of the user's locale (verified under C, C.UTF-8, and en_US.UTF-8). The resulting converter encodes ª (U+00AA) as the single byte 0xAA instead of UTF-8 0xC2 0xAA. Since HFS+/APFS require UTF-8 file names, open() rejects the lone 0xAA with EILSEQ, and completion aborts into PS_ERROR.

The block was written for Linux, where GetSystemEncodingName() returns the locale charset (normally UTF-8), so it's correct there. It has been wrong on macOS since it was added in 2016, and 3.0.1 behaves identically — this is a long-standing bug, not a regression. LC_CTYPE is irrelevant (the converter uses an explicit charset name, not the locale).

The GUI escapes because it never overrides wxConvFileName, keeping wx's default macOS UTF-8 converter (which produces the correct 0xC2 0xAA).

Fix

macOS file systems are always UTF-8, so force encName = "UTF-8" under __WXOSX__. This makes the daemon match the GUI.

Scope / risk

  • macOS: fixes it; no downside — there is no valid Mac-Roman-on-APFS case.
  • Linux: __WXOSX__ undefined → block unchanged → no effect.
  • Windows: the entire __UNIX__ block is already compiled out → no effect.

amulecmd/amuleweb don't override wxConvFileName, so they already use the correct default on macOS.

Verification

macOS Debug+Release builds via CI. Local runtime repro (complete a non-ASCII-named download under amuled, confirm it lands in Incoming/) pending — will update before marking ready.

On macOS wxLocale::GetSystemEncodingName() returns "Mac OS Roman"
regardless of the user's locale, and amuled feeds that into the
wxConvBrokenFileNames it installs as wxConvFileName. Mac Roman encodes
non-ASCII characters as single high bytes (e.g. U+00AA -> 0xAA), which
HFS+/APFS reject as invalid UTF-8 (EILSEQ) when the completed file is
opened. The download is then left in PS_ERROR and never moves from Temp
to Incoming.

macOS file systems are always UTF-8, so force encName to UTF-8 there.
This matches the GUI, which never overrides wxConvFileName and so keeps
wx's default UTF-8 converter (which is why the GUI was unaffected).

Scoped to __WXOSX__: no effect on Linux (block unchanged) or Windows
(the whole __UNIX__ block is compiled out there).
@got3nks
got3nks marked this pull request as ready for review July 6, 2026 12:36
@got3nks
got3nks merged commit c95a776 into amule-org:master Jul 6, 2026
13 checks passed
@got3nks
got3nks deleted the fix/amuled-macos-utf8-filenames branch July 6, 2026 12:38
LSalami added a commit to LSalami/amule that referenced this pull request Jul 28, 2026
…literal

got3nks's review on amule-org#664: a raw ⌥ literal in a narrow string is converted
to wxString via the locale-dependent wxConvLibc, and macOS reports
GetSystemEncodingName() as Mac OS Roman (the same narrow-conversion
quirk amule-org#318 had to work around under __WXOSX__ elsewhere in the tree).
Under a non-UTF-8 conversion those bytes would render as mojibake or
collapse to empty instead of the glyph. wxUniChar(0x2325) builds it from
the codepoint directly, sidestepping the conversion entirely.

po/ regenerated: zero msgid changes, confirming the suffix still never
touches a translated string.

Verified for real this time, not just build-and-run: launched the app
and hovered a toolbar button on macOS -- the tooltip reads "Finestra
reti (⌥N)", the glyph renders correctly.
LSalami added a commit to LSalami/amule that referenced this pull request Jul 28, 2026
…literal

got3nks's review on amule-org#664: a raw ⌥ literal in a narrow string is converted
to wxString via the locale-dependent wxConvLibc, and macOS reports
GetSystemEncodingName() as Mac OS Roman (the same narrow-conversion
quirk amule-org#318 had to work around under __WXOSX__ elsewhere in the tree).
Under a non-UTF-8 conversion those bytes would render as mojibake or
collapse to empty instead of the glyph. wxUniChar(0x2325) builds it from
the codepoint directly, sidestepping the conversion entirely.

po/ regenerated: zero msgid changes, confirming the suffix still never
touches a translated string.

Verified for real this time, not just build-and-run: launched the app
and hovered a toolbar button on macOS -- the tooltip reads "Finestra
reti (⌥N)", the glyph renders correctly.
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