Should std::error_code::message
respect the locale set by the user?
#4711
Labels
bug
Something isn't working
In our program, we use
std::setlocale(LC_ALL, ".UTF8");
to support UTF-8 encoding, as noted in the Microsoft documentation. However, when certain C++ STL functions fail, theirmessage()
outputs are not in UTF-8.After investigating the source code, I found that the error messages are always formatted according to the system's default locale, as shown in this STL implementation:
STL/stl/src/syserror_import_lib.cpp
Lines 38 to 54 in e36ee6c
While it would be acceptable if the system locale used UTF-8 as the codepage, allowing the messages to be correctly printed to log files, this is not the case. There is a "Beta: Use Unicode UTF-8 for worldwide language support" setting in the Region settings, which does the job correctly, but toggling that setting requires a reboot, which is not acceptable for our requirements.
Question
Should the
std::error_code::message
function respect the locale set by the user (e.g., viastd::setlocale
), or should it continue to use the system's default locale? If the former, is there a plan to implement this behavior in the Microsoft STL implementation?Related Information
Please let me know if you need any additional information or clarification.
The text was updated successfully, but these errors were encountered: