Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.