@@ -86,7 +86,7 @@ namespace ZXing.QrCode.Internal | |||||
{ | { | ||||
encoding = DEFAULT_BYTE_MODE_ENCODING; | encoding = DEFAULT_BYTE_MODE_ENCODING; | ||||
} | } | ||||
bool generateECI = !DEFAULT_BYTE_MODE_ENCODING.Equals(encoding); | |||||
bool generateECI = !DEFAULT_BYTE_MODE_ENCODING.Equals(encoding, StringComparison.OrdinalIgnoreCase); | |||||
#else | #else | ||||
// Silverlight supports only UTF-8 and UTF-16 out-of-the-box | // Silverlight supports only UTF-8 and UTF-16 out-of-the-box | ||||
const string encoding = "UTF-8"; | const string encoding = "UTF-8"; | ||||
@@ -1,11 +1,12 @@ | |||||
using Shadowsocks.Properties; | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | |||||
using System.Text.RegularExpressions; | |||||
using System.Globalization; | |||||
using System.IO; | |||||
namespace Shadowsocks.Controller | namespace Shadowsocks.Controller | ||||
{ | { | ||||
using Shadowsocks.Properties; | |||||
public class I18N | public class I18N | ||||
{ | { | ||||
protected static Dictionary<string, string> Strings; | protected static Dictionary<string, string> Strings; | ||||
@@ -13,19 +14,20 @@ namespace Shadowsocks.Controller | |||||
{ | { | ||||
Strings = new Dictionary<string, string>(); | Strings = new Dictionary<string, string>(); | ||||
if (System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag.ToLowerInvariant().StartsWith("zh")) | |||||
if (CultureInfo.CurrentCulture.IetfLanguageTag.StartsWith("zh", StringComparison.OrdinalIgnoreCase)) | |||||
{ | { | ||||
string[] lines = Regex.Split(Resources.cn, "\r\n|\r|\n"); | |||||
foreach (string line in lines) | |||||
using (var sr = new StringReader(Resources.cn)) | |||||
{ | { | ||||
if (line.StartsWith("#")) | |||||
{ | |||||
continue; | |||||
} | |||||
string[] kv = Regex.Split(line, "="); | |||||
if (kv.Length == 2) | |||||
string line; | |||||
while ((line = sr.ReadLine()) != null) | |||||
{ | { | ||||
Strings[kv[0]] = kv[1]; | |||||
if (line[0] == '#') | |||||
continue; | |||||
var pos = line.IndexOf('='); | |||||
if (pos < 1) | |||||
continue; | |||||
Strings[line.Substring(0, pos)] = line.Substring(pos + 1); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -51,12 +51,12 @@ namespace Shadowsocks.Controller | |||||
string[] runList = runKey.GetValueNames(); | string[] runList = runKey.GetValueNames(); | ||||
foreach (string item in runList) | foreach (string item in runList) | ||||
{ | { | ||||
if (item == Key) | |||||
if (item.Equals(Key, StringComparison.OrdinalIgnoreCase)) | |||||
return true; | return true; | ||||
else if (item == "Shadowsocks") // Compatibility with older versions | |||||
else if (item.Equals("Shadowsocks", StringComparison.OrdinalIgnoreCase)) // Compatibility with older versions | |||||
{ | { | ||||
string value = Convert.ToString(runKey.GetValue(item)); | string value = Convert.ToString(runKey.GetValue(item)); | ||||
if (path.Equals(value, StringComparison.InvariantCultureIgnoreCase)) | |||||
if (path.Equals(value, StringComparison.OrdinalIgnoreCase)) | |||||
{ | { | ||||
runKey.DeleteValue(item); | runKey.DeleteValue(item); | ||||
runKey.SetValue(Key, path); | runKey.SetValue(Key, path); | ||||
@@ -76,7 +76,7 @@ namespace Shadowsocks.Controller | |||||
if (runKey != null) | if (runKey != null) | ||||
{ | { | ||||
try { runKey.Close(); } | try { runKey.Close(); } | ||||
catch(Exception e) | |||||
catch (Exception e) | |||||
{ Logging.LogUsefulException(e); } | { Logging.LogUsefulException(e); } | ||||
} | } | ||||
} | } | ||||
@@ -102,11 +102,11 @@ namespace Shadowsocks.Controller | |||||
var connections = registry.GetValueNames(); | var connections = registry.GetValueNames(); | ||||
foreach (var each in connections) | foreach (var each in connections) | ||||
{ | { | ||||
switch (each) | |||||
switch (each.ToUpperInvariant()) | |||||
{ | { | ||||
case "DefaultConnectionSettings": | |||||
case "LAN Connection": | |||||
case "SavedLegacySettings": | |||||
case "DEFAULTCONNECTIONSETTINGS": | |||||
case "LAN CONNECTION": | |||||
case "SAVEDLEGACYSETTINGS": | |||||
continue; | continue; | ||||
default: | default: | ||||
//set all the connections's proxy as the lan | //set all the connections's proxy as the lan | ||||