Skip to content

ExternalConnector: setlocale on init so non-interactive output keeps accented chars (#626) - #629

Merged
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix/amulecmd-locale-init
May 15, 2026
Merged

ExternalConnector: setlocale on init so non-interactive output keeps accented chars (#626)#629
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix/amulecmd-locale-init

Conversation

@got3nks

@got3nks got3nks commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

CaMuleExternalConnector::OnInit() never calls setlocale(), so anything built on it (amulecmd, amuleweb) stays on the default "C" locale unless -l is passed or readline re-initialises it lazily. Show() emits output via:

printf("%s", (const char *)unicode2char(s));

unicode2char is wxConvLibc.cWX2MB(...), which consults LC_CTYPE at runtime. With LC_CTYPE=C, every non-ASCII codepoint collapses to ? on output.

In the interactive amulecmd path, readline calls setlocale(LC_ALL, "") on first prompt, which incidentally fixes the locale before any Show() output runs. In the non-interactive amulecmd -c "show shared" path readline is never touched (TextClient.cpp:227-228) and the locale stays at C. @danim7's repro in #626 shows shared-file paths 333_à / 111_é / 555_â / 444_ü all rendered as ? or garbled byte sequences in -c mode while interactive mode displays them correctly — same data over the same EC channel, only the output-encoding path differs.

Fix

Call setlocale(LC_ALL, "") at the top of CaMuleExternalConnector::OnInit() so the libc locale is sourced from LANG / LC_ALL / LC_CTYPE before anything has a chance to invoke unicode2char(). Adds #include <clocale> for the prototype.

The fix benefits every CaMuleExternalConnector subclass — amulecmd (interactive and -c) and amuleweb (which has its own startup flow but shares the conversion path).

Validation

macOS arm64: amulecmd rebuilds clean.

The interactive path was already working (readline did the locale init for us); the fix removes the dependency on readline being touched first. Non-interactive -c paths now also emit correct UTF-8.

Closes #626.

…amule-project#626)

CaMuleExternalConnector::OnInit() never called setlocale(), so any
process built on it (amulecmd, amuleweb) stayed on the default "C"
locale unless something else (e.g. wxLocale via -l, or readline on
first input) re-initialised it. wxConvLibc -- which unicode2char()
uses to convert wxString -> char* for Show()'s printf -- consults
LC_CTYPE at runtime; with LC_CTYPE=C it collapses every non-ASCII
codepoint to '?'.

In the interactive amulecmd path readline calls setlocale(LC_ALL, "")
on first prompt, which happens to mask the bug -- by the time any
Show() output runs the locale has already been pulled from the env.
The non-interactive `amulecmd -c "show shared"` path never touches
readline, so the locale stays at C and accented filenames in shared/
download listings display as '?' or garbled byte sequences (see
danim7's repro in amule-project#626 -- 333_à / 111_é / 555_â / 444_ü all garbled).

Call setlocale(LC_ALL, "") at the top of CaMuleExternalConnector::
OnInit() so the locale is sourced from the env (LANG / LC_ALL /
LC_CTYPE) before anything has a chance to call unicode2char(). The
fix benefits every CaMuleExternalConnector subclass, not just
amulecmd.

Verified on macOS arm64: amulecmd rebuilds clean.

Reported by danim7.
@danim7

danim7 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Very fast!
It works :)

@mrjimenez
mrjimenez merged commit ef4015c into amule-project:master May 15, 2026
12 checks passed
@got3nks
got3nks deleted the fix/amulecmd-locale-init branch May 16, 2026 16:02
got3nks added a commit to got3nks/amule that referenced this pull request Jul 27, 2026
…mule-project#629)

Add a fully static musl/Alpine build producing self-contained amuled,
amulecmd and amuleapi binaries with no runtime shared-library
dependencies, wired into the existing Linux packaging pipeline:

- packaging/linux/static/ holds the recipe (Dockerfile + README),
  alongside appimage/ and flatpak/. Versions come from versions.env
  (wx / Crypto++ / libupnp, SHA256-verified) — no pins in the Dockerfile.
- packaging/linux/build.sh gains a 'static' target mirroring the other
  tracks; packaging.yml gains a linux-static matrix job (x86_64 + aarch64
  native runners) that calls it, with a buildx gha layer cache disabled on
  workflow_call so release builds cold-compile.
- release.yml downloads the linux-static-* artifacts into the draft with a
  manifest check like the other platforms.

Feature set: UPnP, IP2Country, BFD backtraces, NLS, wxWebRequest downloads.
Monolithic GUI excluded — wxGTK dlopen()s modules, so it cannot be static.
Ships one tarball per arch: aMule-<ver>-Linux-<x64|arm64>-static.tar.gz.
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.

amulecmd --command="show shared" not displaying accented characters

3 participants