Skip to content

Commit 69cfe0d

Browse files
authored
FIX: The function wstring_to_std_string does not correctly convert wstring to UTF-8 encoded string, which causes a crash when fmt prints strings in system_infoMain.cpp later on. (#120)
1 parent 642c756 commit 69cfe0d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

include/hwinfo/utils/stringutils.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ inline std::string wstring_to_string() { return ""; }
180180
* @return
181181
*/
182182
inline std::string wstring_to_std_string(const std::wstring& ws) {
183-
std::string str_locale = std::setlocale(LC_ALL, "");
183+
std::string str_locale = std::setlocale(LC_ALL, NULL);
184+
185+
#if _MSC_VER
186+
std::setlocale(LC_ALL, ".65001");
187+
#else
188+
std::setlocale(LC_ALL, ".UTF-8");
189+
#endif
184190
const wchar_t* wch_src = ws.c_str();
185191

186192
#ifdef _MSC_VER

0 commit comments

Comments
 (0)