Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Decodes an encoded URL
- /// </summary>
- /// <param name="str">Input URL</param>
- /// <returns>decoded URL</returns>
- public static string Decode(string str)
- {
- Regex hexReg = new Regex(@"%(?<value>[A-E\d]{2})");
- StringBuilder b = new StringBuilder(str);
- int offset = 0;
- MatchCollection matches = hexReg.Matches(str);
- foreach (Match m in matches)
- {
- string hexValue = m.Groups[1].Value;
- int decValue = Convert.ToInt32(hexValue, 16);
- string charValue = Char.ConvertFromUtf32(decValue);
- b.Remove(m.Index - offset, m.Length);
- b.Insert(m.Index - offset, charValue);
- offset += m.Length - charValue.Length;
- }
- return b.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement