Skip to content

Instantly share code, notes, and snippets.

@alexsandro-xpt
Created September 17, 2012 18:51
Show Gist options
  • Save alexsandro-xpt/3739062 to your computer and use it in GitHub Desktop.
Save alexsandro-xpt/3739062 to your computer and use it in GitHub Desktop.
C# JavaScript unescape function
public static string unescape(string code)
{
var str = Regex.Replace(code, @"\+", "\x20");
str = Regex.Replace(str, @"%([a-fA-F0-9][a-fA-F0-9])", new MatchEvaluator((mach) => {
var _tmp = mach.Groups[0].Value;
var _hexC = mach.Groups[1].Value;
var _hexV = int.Parse(_hexC, System.Globalization.NumberStyles.HexNumber);
return ((char)_hexV).ToString();
}));
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment