Linux: CJK IME text not committed when bare "en_US" locale is missing

Summary

UE forces LC_NUMERIC=en_US via setenv() in CommonUnixMain (Engine/Source/Runtime/Unix/UnixCommonStartup/Private/UnixCommonStartup.cpp) to enforce US numeric formatting. On distributions whose glibc locale archive only ships en_US.utf8 / en_US.UTF-8 (no bare en_US; glibc’s setlocale() never auto-appends a codeset suffix), every later setlocale(LC_ALL, "") in the process fails with ENOENT, leaving the whole process in the “C” locale. With locale “C”, libX11’s XIM encoding negotiation (imDefIm.c _XimSetEncodingByName) produces an empty encoding name list; the IM server (fcitx5) falls back to index 0; _XimGetEncoding finds no match in the client’s local (empty) list, so the CT (Compound Text) converter is never opened and committed CJK text is silently dropped at Xutf8LookupString. English input is unaffected (keysym path).

Why older releases worked: UE ≤5.6 shipped SDL2, whose X11 driver bypassed XIM entirely when XMODIFIERS contained @im=fcitx (forcing @im=none and using its own fcitx DBus text input, src/core/linux/SDL_fcitx.c). UE 5.7+ switched to SDL3, which dropped that workaround and does not wire DBus IME for the X11 driver, so XIM became the only path and the latent bug (introduced 2018, see commit 41e05944 which replaced a defensive setlocale(LC_CTYPE,"") with setlocale(LC_ALL,"") ignoring the return value) became visible. A one-line fix resolves it: setenv("LC_NUMERIC", "en_US.UTF-8", 1) (preserves US numeric formatting, verified identical localeconv() output; en_US.UTF-8 resolves on all distros).

What Type of Bug are you experiencing?

Editor

Steps to Reproduce

  1. Use a Linux distribution whose locale list has no bare en_US (Arch Linux: locale -a shows only C, C.utf8, en_US.utf8, POSIX, zh_CN.utf8; Ubuntu’s default is similar).

  2. In a KDE/Wayland session (XWayland), launch the editor with the X11 SDL driver: SDL_VIDEODRIVER=x11 ./Engine/Binaries/Linux/UnrealEditor .uproject, with fcitx5 running as the input method.

  3. Focus a text field (e.g. in the Content Browser search box or a Blueprint comment), switch the IME to Chinese, type a pinyin sequence (e.g. “nihao”) and select a candidate from the popup.

Expected Result

The selected Chinese text is committed into the text field.

Observed Result

The candidate popup appears normally, but after selecting a candidate no text is committed and no error is logged. English typing works fine. Verified on UE 5.8.1; the bug reproduces 100% of the time.

Affects Versions

5.8

Platform(s)

Linux

Additional Notes

The root-cause analysis behind this report was done collaboratively between me and an AI coding assistant. The heavy lifting — writing and running the libX11 instrumentation shim, capturing the XIM wire-protocol traffic, in-process locale probing, tracing the git history back to 2018, and correlating the SDL2→SDL3 behavior change — was carried out by the AI; all runtime verification (launching the editor, reproducing the bug, and confirming the one-line fix works) was performed manually by the human. Every claim in this report is backed by captured logs and live experiments, not speculation. The fix has been validated end-to-end on UE 5.8.1 (CJK text commits successfully after changing setenv("LC_NUMERIC", "en_US", 1) to "en_US.UTF-8").