Browse Source

Retry with UTF16LE when parse sysproxy output fail

tags/4.1.3
StudentEx 6 years ago
parent
commit
41cdca649f
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs

+ 10
- 0
shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs View File

@@ -193,6 +193,16 @@ namespace Shadowsocks.Util.SystemProxy
private static void ParseQueryStr(string str)
{
string[] userSettingsArr = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
// sometimes sysproxy output in utf16le instead of ascii
// manually translate it
if (userSettingsArr.Length == 1)
{
byte[] strByte = Encoding.ASCII.GetBytes(str);
str = Encoding.Unicode.GetString(strByte);
userSettingsArr = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
}
_userSettings.Flags = userSettingsArr[0];
// handle output from WinINET


Loading…
Cancel
Save