Skip to content

common: replace deprecated wstring_convert with Win32 conversion APIs - #2493

Open
ronaldtse wants to merge 1 commit into
mainfrom
fix-2302-wstring-convert
Open

ronaldtse wants to merge 1 commit into
mainfrom
fix-2302-wstring-convert

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the deprecated std::wstring_convert / std::codecvt_utf8_utf16 pair used by the Windows UTF-8 helpers, as reported by @ni4 in Consider replacing std::wstring_convert with appropriate alternative for Windows. #2302.
  • The helpers now call MultiByteToWideChar and WideCharToMultiByte, which are the supported conversion APIs on modern Windows toolchains and avoid the known Microsoft STL memory leak in wstring_convert.
  • The throwing-on-error contract of the previous helpers is preserved, and the existing Windows Unicode CLI tests continue to exercise the conversion path.

Test plan

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

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.
@ronaldtse

Copy link
Copy Markdown
Contributor Author

@ni4 per your issue #2302, this replaces the deprecated std::wstring_convert with the Win32 conversion APIs, preserving the throwing contract and keeping the existing Windows Unicode tests as coverage. 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.45%. Comparing base (26482f6) to head (fa1f3e5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2493   +/-   ##
=======================================
  Coverage   85.45%   85.45%           
=======================================
  Files         125      125           
  Lines       23042    23042           
=======================================
  Hits        19691    19691           
  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.

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