Skip to content

Replace wstring_convert with the Win32 conversion functions - #308

Open
mnightingale wants to merge 2 commits into
Parchive:masterfrom
mnightingale:libpar2/utf8-drop-codecvt
Open

Replace wstring_convert with the Win32 conversion functions#308
mnightingale wants to merge 2 commits into
Parchive:masterfrom
mnightingale:libpar2/utf8-drop-codecvt

Conversation

@mnightingale

Copy link
Copy Markdown
Contributor

<codecvt> and std::wstring_convert were deprecated in C++17 and are removed in C++26, so utf8.cpp has to move off them eventually. This replaces them with MultiByteToWideChar/WideCharToMultiByte.

MB_ERR_INVALID_CHARS and WC_ERR_INVALID_CHARS are not new strictness, they preserve the old behaviour.
wstring_convert threw std::range_error on ill-formed input and the code caught it; without those flags the replacement would silently substitute U+FFFD instead.
The conversions now return bool and report failure to the caller rather than logging and returning an empty string.

Two bugs fixed:

  • The long-path prefix for UNC paths doubled the separator, producing \\?\UNC\\server\share
  • WideToUtf8ArgsAdapter mishandled a null in wargv: --m_argc; --i; continue; re-examines the same index while shrinking the count, so one null argument dropped every argument

utf8.{h,cpp} is now #ifdef _WIN32, since it is Win32-only; the unit test exits 77 (SKIP) elsewhere.

@mnightingale
mnightingale force-pushed the libpar2/utf8-drop-codecvt branch from b9026ea to a799d0f Compare August 31, 2026 20:22
@mnightingale
mnightingale force-pushed the libpar2/utf8-drop-codecvt branch from a799d0f to 957b1c8 Compare September 5, 2026 15:52
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