Skip to content

Instantly share code, notes, and snippets.

@dtinth
Created May 14, 2011 14:53
Show Gist options
  • Save dtinth/972288 to your computer and use it in GitHub Desktop.
Save dtinth/972288 to your computer and use it in GitHub Desktop.
var el = document.querySelector('textarea.file-contents');
el.value = el.value.replace(/[\s\S]/g, function(a) {
if (a.charCodeAt(0) > 127)
return encodeURIComponent(a).replace(/%/g, '\\x');
return a;
});
s.Replace( "a", "\xC3\xA0\xC3\xA1" );
s.Replace( "A", "\xC3\x80\xC3\x80" );
s.Replace( "e", "\xC3\xA9\xC3\xA9" );
s.Replace( "E", "\xC3\x89\xC3\x89" );
s.Replace( "i", "\xC3\xAD\xC3\xAD" );
s.Replace( "I", "\xC3\x8D\xC3\x8D" );
s.Replace( "o", "\xC3\xB3\xC3\xB3" );
s.Replace( "O", "\xC3\x93\xC3\x93" );
s.Replace( "u", "\xC3\xBC\xC3\xBC" );
s.Replace( "U", "\xC3\x9C\xC3\x9C" );
s.Replace( "n", "\xC3\xB1" );
s.Replace( "N", "\xC3\x91" );
s.Replace( "c", "\xC3\xA7" );
s.Replace( "C", "\xC3\x87" );
// transformations that help expose punctuation assumptions
//s.Replace( ":", " :" ); // this messes up "::" help text tip separator markers
s.Replace( "?", " ?" );
s.Replace( "!", " !" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment