Changeset View
Changeset View
Standalone View
Standalone View
src/fs.cpp
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
std::string get_filesystem_error_message(const fs::filesystem_error &e) { | std::string get_filesystem_error_message(const fs::filesystem_error &e) { | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
return e.what(); | return e.what(); | ||||
#else | #else | ||||
// Convert from Multi Byte to utf-16 | // Convert from Multi Byte to utf-16 | ||||
std::string mb_string(e.what()); | std::string mb_string(e.what()); | ||||
int size = MultiByteToWideChar(CP_ACP, 0, mb_string.c_str(), | int size = MultiByteToWideChar(CP_ACP, 0, mb_string.data(), | ||||
mb_string.size(), nullptr, 0); | mb_string.size(), nullptr, 0); | ||||
std::wstring utf16_string(size, L'\0'); | std::wstring utf16_string(size, L'\0'); | ||||
MultiByteToWideChar(CP_ACP, 0, mb_string.c_str(), mb_string.size(), | MultiByteToWideChar(CP_ACP, 0, mb_string.data(), mb_string.size(), | ||||
&*utf16_string.begin(), size); | &*utf16_string.begin(), size); | ||||
// Convert from utf-16 to utf-8 | // Convert from utf-16 to utf-8 | ||||
return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t>() | return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t>() | ||||
.to_bytes(utf16_string); | .to_bytes(utf16_string); | ||||
#endif | #endif | ||||
} | } | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |