Skip to content

Commit d83404d

Browse files
sailroGitHub Enterprise
authored andcommitted
Merge pull request #179 from unity/utf8-cp
Workaround specific UTF8 issue with non-UTF code pages like 949 (Korea)
2 parents 128e920 + 218e853 commit d83404d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Packages/com.unity.ide.visualstudio/Editor/VisualStudioForWindowsInstallation.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,24 @@ private static IEnumerable<VisualStudioInstallation> QueryVsWhere()
228228
if (string.IsNullOrWhiteSpace(progpath))
229229
return Enumerable.Empty<VisualStudioInstallation>();
230230

231-
var result = ProcessRunner.StartAndWaitForExit(progpath, "-prerelease -format json -utf8");
231+
const string arguments = "-prerelease -format json";
232+
233+
// We've seen issues with json parsing in utf8 mode and with specific non-UTF code pages like 949 (Korea)
234+
// So try with utf8 first, then fallback to non utf8 in case of an issue
235+
// See https://github.com/microsoft/vswhere/issues/264
236+
try
237+
{
238+
return QueryVsWhere(progpath, $"{arguments} -utf8");
239+
}
240+
catch
241+
{
242+
return QueryVsWhere(progpath, $"{arguments}");
243+
}
244+
}
245+
246+
private static IEnumerable<VisualStudioInstallation> QueryVsWhere(string progpath, string arguments)
247+
{
248+
var result = ProcessRunner.StartAndWaitForExit(progpath, arguments);
232249

233250
if (!result.Success)
234251
throw new Exception($"Failure while running vswhere: {result.Error}");

0 commit comments

Comments
 (0)