Skip to content

Instantly share code, notes, and snippets.

@jwalsh
Created September 6, 2012 18:10
Show Gist options
  • Save jwalsh/3659067 to your computer and use it in GitHub Desktop.
Save jwalsh/3659067 to your computer and use it in GitHub Desktop.
var chars = ['#', '&', ';', ':', '/', '\\', '\'', '"', 'A',
'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç',
'È', 'É', 'Ê', 'Ë',
'Ì', 'Í', 'Î', 'Ï',
'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö',
'×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü',
'Ý', 'Þ', 'ß',
'à', 'á', 'â', 'ã', 'ä', 'å',
'æ', 'ç', 'è', 'é', 'ê', 'ë',
'ì', 'í', 'î', 'ï',
'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö',
'÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ'];
console.log('chars[c]',
'encodeURIComponent(chars[c])',
'escape(chars[c])',
'unescape(encodeURIComponent(chars[c]))',
'equal');
for (var c in chars) {
console.log(chars[c],
encodeURIComponent(chars[c]),
escape(chars[c]),
unescape(encodeURIComponent(chars[c])),
unescape(encodeURIComponent(chars[c])) === chars[c]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment