@samitouri / QOSAMI-WSL / commits / b89e1f58

Fix json invalid utf-8 from IconPath (#13340)

When storing the IconPath value directly as a string we are subject to unspecified behaviour as Windows stores paths as 16-bit wchar_t and std::string doesn't convey a specific char encoding. To be specific we need to access the icon path in its native format (which we assume to be std::wstring) and convert it to multibyte.

Carlos Nihelton committed Aug 5, 2025 at 15:27 UTC b89e1f58c920a3850ed053072976a635f4bbadf7
1 file changed +1 -1
src/windows/service/exe/LxssUserSession.cpp
+1 -1
@@ -2683,7 +2683,7 @@ try
2683
2684 e["name"] = WideToMultiByte(Configuration.Name);
2685 e["guid"] = WideToMultiByte(distributionProfileId);
2686 - e["icon"] = IconPath.string();
2686 + e["icon"] = WideToMultiByte(IconPath.native());
2687
2688 // See https://github.com/microsoft/terminal/pull/18195. Supported in terminal >= 1.23
2689 e["pathTranslationStyle"] = "wsl";