Windows `system_category::message()` uses the wrong encoding
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
#93101 changed `system_category::message()` on Windows to use `FormatMessageA`.
This returns text in the Windows ANSI code page, while `error_category::message()` is otherwise expected to return text in the execution character set.
That caused a major regression by making the interface impossible to use polymorphically: code calling `ec.message()` cannot know how to interpret the returned `std::string` without checking `ec.category()` and special-casing `system_category()`.
This was clarified by [LWG 4156](https://cplusplus.github.io/LWG/issue4156) / [P3395](https://wg21.link/P3395R6) adopted in C++26, which specifies that `error_category::message()` returns text in the execution character set.
`system_category::message()` should use `FormatMessageW` and transcode to the execution character set.
Contributor guide
Research direction
Locate the Windows implementation of system_category::message() and the tests covering error_category messages. Read how Windows error text is currently obtained and how execution-character-set conversion is handled elsewhere. Done means the implementation follows LWG 4156/P3395 by returning compatible execution-character-set text without category-specific handling by callers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100