Skip to content

Instantly share code, notes, and snippets.

@gfranko
Created June 21, 2016 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfranko/460171e24839c9919fdab1eca7a4539b to your computer and use it in GitHub Desktop.
Save gfranko/460171e24839c9919fdab1eca7a4539b to your computer and use it in GitHub Desktop.
var accentMap = {
'à': 'a', 'á': 'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', // a
'ç': 'c', // c
'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', // e
'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', // i
'ñ': 'n', // n
'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ø': 'o', // o
'ß': 's', // s
'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', // u
'ÿ': 'y' // y
};
// Replaces accents from the passed in string
var replaceAccent = function replaceAccentCallback (str) {
str = str || '';
return str.split('').map(function (character) {
return accentMap[character] || character;
}).join('');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment