Skip to content

cli: enter through wmain on Windows and link MinGW with -municode - #2494

Open
ronaldtse wants to merge 3 commits into
mainfrom
fix-2288-wmain
Open

ronaldtse wants to merge 3 commits into
mainfrom
fix-2288-wmain

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

  • Addresses Consider to use wmain/-municode when linking MSYS build. #2288: the production entry points of rnp and rnpkeys now enter through wmain on Windows, so the process receives UTF-16 arguments from the OS and converts them to UTF-8 once at startup before calling the existing rnp_main / rnpkeys_main bodies.
  • MinGW targets are linked with -municode so the Unicode entry point is selected; MSVC selects wmain automatically when it is present.
  • The rnp_main / rnpkeys_main symbols remain available for the test suite, which continues to pass UTF-8 char ** arguments directly and does not go through wmain.
  • Depends on common: replace deprecated wstring_convert with Win32 conversion APIs #2493 for the Win32 UTF-8 helpers used by the conversion.

Test plan

  • windows-native and windows-msys2 matrices pass
  • the existing Unicode CLI tests continue to pass on Windows

@ronaldtse

Copy link
Copy Markdown
Contributor Author

@ni4 this implements the wmain/-municode direction from #2288: the production entry points take UTF-16 from the OS and convert to UTF-8 once at startup, while the test suite keeps calling rnp_main/rnpkeys_main directly. It is stacked on #2493 for the Win32 conversion helpers. Whenever convenient, a review would be appreciated.

@ronaldtse
ronaldtse requested a review from ni4 September 21, 2026 09:24
@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.47%. Comparing base (bdabdf9) to head (87ee6b3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2494      +/-   ##
==========================================
+ Coverage   85.45%   85.47%   +0.01%     
==========================================
  Files         125      125              
  Lines       23042    23067      +25     
==========================================
+ Hits        19691    19716      +25     
  Misses       3351     3351              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

std::wstring_convert and std::codecvt_utf8_utf16 are deprecated as of
C++17 and the Microsoft STL implementation leaks memory, as reported in
issue #2302. The UTF-8/UTF-16 helpers now use MultiByteToWideChar and
WideCharToMultiByte, which are the supported path on modern Windows
toolchains and keep the same throwing-on-error contract the previous
helpers used.
Recent MinGW builds default argv to the system ANSI code page, which is
not always UTF-8, as reported in issue #2288. The production entry
points now use wmain so the OS supplies UTF-16 arguments, convert them
to UTF-8 once at startup, and then call the existing rnp_main /
rnpkeys_main bodies. MinGW targets are linked with -municode so the
Unicode entry point is selected. The rnp_main/rnpkeys_main symbols
remain available for the test suite, which continues to pass UTF-8
char** arguments directly.
The wmain entry points call rnp_main and rnpkeys_main, but the forward
declarations were inside the RNP_RUN_TESTS block and therefore absent
from the production build, which broke compilation on every non-Windows
workflow.

This branch has not been deployed

No deployments
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