public static string UrlDecode(string url) { if (url == null) { return(null); } Utility._UrlDecoder urlDecoder = new Utility._UrlDecoder(url.Length, Encoding.UTF8); int length = url.Length; for (int i = 0; i < length; i++) { char c = url[i]; if (c == '+') { urlDecoder.AddByte(32); } else { if (c == '%' && i < length - 2) { if (url[i + 1] == 'u' && i < length - 5) { int num = Utility._HexToInt(url[i + 2]); int num2 = Utility._HexToInt(url[i + 3]); int num3 = Utility._HexToInt(url[i + 4]); int num4 = Utility._HexToInt(url[i + 5]); if (num >= 0 && num2 >= 0 && num3 >= 0 && num4 >= 0) { urlDecoder.AddChar((char)(num << 12 | num2 << 8 | num3 << 4 | num4)); i += 5; goto IL_12D; } } else { int num5 = Utility._HexToInt(url[i + 1]); int num6 = Utility._HexToInt(url[i + 2]); if (num5 >= 0 && num6 >= 0) { urlDecoder.AddByte((byte)(num5 << 4 | num6)); i += 2; goto IL_12D; } } } if ((c & 'タ') == '\0') { urlDecoder.AddByte((byte)c); } else { urlDecoder.AddChar(c); } } IL_12D :; } return(urlDecoder.GetString()); }
public static string UrlDecode(string url) { if (url == null) { return(null); } Utility._UrlDecoder __UrlDecoder = new Utility._UrlDecoder(url.Length, Encoding.UTF8); int length = url.Length; for (int i = 0; i < length; i++) { char chr = url[i]; if (chr != '+') { if (chr == '%' && i < length - 2) { if (url[i + 1] != 'u' || i >= length - 5) { int num = Utility._HexToInt(url[i + 1]); int num1 = Utility._HexToInt(url[i + 2]); if (num < 0 || num1 < 0) { goto Label1; } __UrlDecoder.AddByte((byte)(num << 4 | num1)); i += 2; goto Label0; } else { int num2 = Utility._HexToInt(url[i + 2]); int num3 = Utility._HexToInt(url[i + 3]); int num4 = Utility._HexToInt(url[i + 4]); int num5 = Utility._HexToInt(url[i + 5]); if (num2 < 0 || num3 < 0 || num4 < 0 || num5 < 0) { goto Label1; } __UrlDecoder.AddChar((char)(num2 << 12 | num3 << 8 | num4 << 4 | num5)); i += 5; goto Label0; } } Label1: if ((chr & '\uFF80') != 0) { __UrlDecoder.AddChar(chr); } else { __UrlDecoder.AddByte((byte)chr); } } else { __UrlDecoder.AddByte(32); } Label0: } return(__UrlDecoder.GetString()); }