зеркало из https://github.com/microsoft/STL.git
<system_error>: explicitly pass the system locale ID for system_category messages (#2669)
This commit is contained in:
Родитель
b965db4e56
Коммит
fa51112a5a
|
@ -45,9 +45,15 @@ _NODISCARD size_t __CLRCALL_PURE_OR_STDCALL __std_system_error_allocate_message(
|
|||
// convert to name of Windows error, return 0 for failure, otherwise return number of chars in buffer
|
||||
// __std_system_error_deallocate_message should be called even if 0 is returned
|
||||
// pre: *_Ptr_str == nullptr
|
||||
DWORD _Lang_id;
|
||||
const int _Ret = GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_ILANGUAGE | LOCALE_RETURN_NUMBER,
|
||||
reinterpret_cast<LPWSTR>(&_Lang_id), sizeof(_Lang_id) / sizeof(wchar_t));
|
||||
if (_Ret == 0) {
|
||||
_Lang_id = 0;
|
||||
}
|
||||
const unsigned long _Chars =
|
||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr, _Message_id, 0, reinterpret_cast<char*>(_Ptr_str), 0, nullptr);
|
||||
nullptr, _Message_id, _Lang_id, reinterpret_cast<char*>(_Ptr_str), 0, nullptr);
|
||||
|
||||
return _CSTD __std_get_string_size_without_trailing_whitespace(*_Ptr_str, _Chars);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче