Skip to content

Instantly share code, notes, and snippets.

@MiguelQueiroz
Last active August 29, 2015 14:02
Show Gist options
  • Save MiguelQueiroz/75d008fde4bc3289bd84 to your computer and use it in GitHub Desktop.
Save MiguelQueiroz/75d008fde4bc3289bd84 to your computer and use it in GitHub Desktop.
function replaceAccents(s)
{
var map_char={ 'À':'A', 'Á':'A', 'Â':'A', 'Ã':'A', 'Ä':'Ae', 'Å':'A', 'Æ':'A', 'Ă':'A',
'à':'a', 'á':'a', 'â':'a', 'ã':'a', 'ä':'ae', 'å':'a', 'ă':'a', 'æ':'ae','þ':'b', 'Þ':'B',
'Ç':'C', 'ç':'c','È':'E', 'É':'E', 'Ê':'E', 'Ë':'E','è':'e', 'é':'e', 'ê':'e', 'ë':'e',
'Ğ':'G', 'ğ':'g',
'Ì':'I', 'Í':'I', 'Î':'I', 'Ï':'I', 'İ':'I', 'ı':'i', 'ì':'i', 'í':'i', 'î':'i', 'ï':'i',
'Ñ':'N','Ò':'O', 'Ó':'O', 'Ô':'O', 'Õ':'O', 'Ö':'Oe', 'Ø':'O', 'ö':'oe', 'ø':'o',
'ð':'o', 'ñ':'n', 'ò':'o', 'ó':'o', 'ô':'o', 'õ':'o',
'Š':'S', 'š':'s', 'Ş':'S', 'ș':'s', 'Ș':'S', 'ş':'s', 'ß':'ss',
'ț':'t', 'Ț':'T',
'Ù':'U', 'Ú':'U', 'Û':'U', 'Ü':'Ue',
'ù':'u', 'ú':'u', 'û':'u', 'ü':'ue',
'Ý':'Y',
'ý':'y', 'ý':'y', 'ÿ':'y',
'Ž':'Z', 'ž':'z'};
var tmp="";
for(i=0; i<s.length; i++)
{
tmp+= map_char[s[i]]?map_char[s[i]]:s[i];
}
return(tmp);
}
$("#ea").html(replaceAccents("Hello Migueção"));
var st=replaceAccents("Hello Caça"); //Hello Caca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment