Skip to content

fix(simu): force C locale for numeric parsing in simulator - #7613

Open
bultodepapas wants to merge 1 commit into
EdgeTX:mainfrom
bultodepapas:fix/simu-force-c-locale
Open

fix(simu): force C locale for numeric parsing in simulator#7613
bultodepapas wants to merge 1 commit into
EdgeTX:mainfrom
bultodepapas:fix/simu-force-c-locale

Conversation

@bultodepapas

Copy link
Copy Markdown

Fixes #7453

Summary

The Companion / SDL simulator failed to run when the host locale is not C/English (e.g. LANG=es_ES.UTF-8): all float numbers parsed by the Lua engine produced errors because strtof/strtod use the locale's decimal separator (, in es_ES) instead of ..

Fix

Force LC_NUMERIC to "C" in simuInit() (radio/src/targets/simu/simulib.cpp), which is the shared entry point for both the SDL and the WASM simulator. This makes numeric conversions locale-independent inside the simulator while leaving the rest of the process untouched.

Verification

Compiled a small host test that calls setlocale(LC_NUMERIC, "C") and confirmed strtod("1.5") parses correctly regardless of the host locale.

Copilot AI review requested due to automatic review settings August 3, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes simulator failures under non-C host locales by forcing locale-independent numeric parsing (so Lua number parsing via strtof/strtod continues to expect . as the decimal separator). The change is applied in simuInit(), the shared simulator entry point used by SDL, tests, and the WASM host.

Changes:

  • Force LC_NUMERIC to "C" during simulator initialization to prevent locale-dependent float parsing.
  • Add the required locale header include (<clocale>) for setlocale.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pfeerick pfeerick added bug 🪲 Something isn't working simulator translation labels Aug 4, 2026
@pfeerick pfeerick changed the title fix(simu): force C locale for numeric parsing in simulator (#7453) fix(simu): force C locale for numeric parsing in simulator Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Companion - Simulator - does not work for LANG values other than English or C

3 participants