Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Accent Folding in Javascript
var accent_map = {
'':'a','Á':'a','á':'a','À':'a','à':'a','Ă':'a','ă':'a','':'a','':'a','':'a','':'a','':'a','':'a','':'a','':'a','Â':'a','â':'a','':'a','':'a','':'a','':'a','':'a','':'a','':'a','':'a','Ǎ':'a','ǎ':'a','Å':'a','å':'a','Ǻ':'a','ǻ':'a','Ä':'a','ä':'a','Ǟ':'a','ǟ':'a','Ã':'a','ã':'a','Ȧ':'a','ȧ':'a','Ǡ':'a','ǡ':'a','Ą':'a','ą':'a','Ā':'a','ā':'a','':'a','':'a','Ȁ':'a','ȁ':'a','Ȃ':'a','ȃ':'a','':'a','':'a','':'a','':'a','':'a','':'a','':'a','':'a','Ⱥ':'a','':'a','Ǽ':'a','ǽ':'a','Ǣ':'a','ǣ':'a',
'':'b','':'b','':'b','':'b','':'b','':'b','Ƀ':'b','ƀ':'b','':'b','Ɓ':'b','ɓ':'b','Ƃ':'b','ƃ':'b',
'Ć':'c','ć':'c','Ĉ':'c','ĉ':'c','Č':'c','č':'c','Ċ':'c','ċ':'c','Ç':'c','ç':'c','':'c','':'c','Ȼ':'c','ȼ':'c','Ƈ':'c','ƈ':'c','ɕ':'c',
'Ď':'d','ď':'d','':'d','':'d','':'d','':'d','':'d','':'d','':'d','':'d','':'d','':'d','Đ':'d','đ':'d','':'d','Ɖ':'d','ɖ':'d','Ɗ':'d','ɗ':'d','Ƌ':'d','ƌ':'d','ȡ':'d','ð':'d',
'É':'e','Ə':'e','Ǝ':'e','ǝ':'e','é':'e','È':'e','è':'e','Ĕ':'e','ĕ':'e','Ê':'e','ê':'e','':'e','ế':'e','':'e','':'e','':'e','':'e','':'e','':'e','Ě':'e','ě':'e','Ë':'e','ë':'e','':'e','':'e','Ė':'e','ė':'e','Ȩ':'e','ȩ':'e','':'e','':'e','Ę':'e','ę':'e','Ē':'e','ē':'e','':'e','':'e','':'e','':'e','':'e','':'e','Ȅ':'e','ȅ':'e','Ȇ':'e','ȇ':'e','':'e','':'e','':'e','':'e','':'e','':'e','':'e','':'e','Ɇ':'e','ɇ':'e','ɚ':'e','ɝ':'e',
'':'f','':'f','':'f','Ƒ':'f','ƒ':'f',
'Ǵ':'g','ǵ':'g','Ğ':'g','ğ':'g','Ĝ':'g','ĝ':'g','Ǧ':'g','ǧ':'g','Ġ':'g','ġ':'g','Ģ':'g','ģ':'g','':'g','':'g','Ǥ':'g','ǥ':'g','Ɠ':'g','ɠ':'g',
'Ĥ':'h','ĥ':'h','Ȟ':'h','ȟ':'h','':'h','':'h','':'h','':'h','':'h','':'h','':'h','':'h','':'h','':'h','H':'h','̱':'h','':'h','Ħ':'h','ħ':'h','':'h','':'h',
'Í':'i','í':'i','Ì':'i','ì':'i','Ĭ':'i','ĭ':'i','Î':'i','î':'i','Ǐ':'i','ǐ':'i','Ï':'i','ï':'i','':'i','':'i','Ĩ':'i','ĩ':'i','İ':'i','i':'i','Į':'i','į':'i','Ī':'i','ī':'i','':'i','':'i','Ȉ':'i','ȉ':'i','Ȋ':'i','ȋ':'i','':'i','':'i','':'i','':'i','I':'i','ı':'i','Ɨ':'i','ɨ':'i',
'Ĵ':'j','ĵ':'j','J':'j','̌':'j','ǰ':'j','ȷ':'j','Ɉ':'j','ɉ':'j','ʝ':'j','ɟ':'j','ʄ':'j',
'':'k','':'k','Ǩ':'k','ǩ':'k','Ķ':'k','ķ':'k','':'k','':'k','':'k','':'k','Ƙ':'k','ƙ':'k','':'k','':'k',
'Ĺ':'l','ĺ':'l','Ľ':'l','ľ':'l','Ļ':'l','ļ':'l','':'l','':'l','':'l','':'l','':'l','':'l','':'l','':'l','Ł':'l','ł':'l','Ł':'l','̣':'l','ł':'l','̣':'l','Ŀ':'l','ŀ':'l','Ƚ':'l','ƚ':'l','':'l','':'l','':'l','ɫ':'l','ɬ':'l','ɭ':'l','ȴ':'l',
'':'m','ḿ':'m','':'m','':'m','':'m','':'m','ɱ':'m',
'Ń':'n','ń':'n','Ǹ':'n','ǹ':'n','Ň':'n','ň':'n','Ñ':'n','ñ':'n','':'n','':'n','Ņ':'n','ņ':'n','':'n','':'n','':'n','':'n','':'n','':'n','Ɲ':'n','ɲ':'n','Ƞ':'n','ƞ':'n','ɳ':'n','ȵ':'n','N':'n','̈':'n','n':'n','̈':'n',
'Ó':'o','ó':'o','Ò':'o','ò':'o','Ŏ':'o','ŏ':'o','Ô':'o','ô':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','Ǒ':'o','ǒ':'o','Ö':'o','ö':'o','Ȫ':'o','ȫ':'o','Ő':'o','ő':'o','Õ':'o','õ':'o','':'o','':'o','':'o','':'o','Ȭ':'o','ȭ':'o','Ȯ':'o','ȯ':'o','Ȱ':'o','ȱ':'o','Ø':'o','ø':'o','Ǿ':'o','ǿ':'o','Ǫ':'o','ǫ':'o','Ǭ':'o','ǭ':'o','Ō':'o','ō':'o','':'o','':'o','':'o','':'o','':'o','':'o','Ȍ':'o','ȍ':'o','Ȏ':'o','ȏ':'o','Ơ':'o','ơ':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','':'o','Ɵ':'o','ɵ':'o',
'':'p','':'p','':'p','':'p','':'p','Ƥ':'p','ƥ':'p','P':'p','̃':'p','p':'p','̃':'p',
'ʠ':'q','Ɋ':'q','ɋ':'q',
'Ŕ':'r','ŕ':'r','Ř':'r','ř':'r','':'r','':'r','Ŗ':'r','ŗ':'r','Ȑ':'r','ȑ':'r','Ȓ':'r','ȓ':'r','':'r','':'r','':'r','':'r','':'r','':'r','Ɍ':'r','ɍ':'r','':'r','ɼ':'r','':'r','ɽ':'r','ɾ':'r','':'r',
'ß':'s','Ś':'s','ś':'s','':'s','':'s','Ŝ':'s','ŝ':'s','Š':'s','š':'s','':'s','':'s','':'s','':'s','':'s','Ş':'s','ş':'s','':'s','':'s','':'s','':'s','Ș':'s','ș':'s','ʂ':'s','S':'s','̩':'s','s':'s','̩':'s',
'Þ':'t','þ':'t','Ť':'t','ť':'t','T':'t','̈':'t','':'t','':'t','':'t','Ţ':'t','ţ':'t','':'t','':'t','Ț':'t','ț':'t','':'t','':'t','':'t','':'t','Ŧ':'t','ŧ':'t','Ⱦ':'t','':'t','':'t','ƫ':'t','Ƭ':'t','ƭ':'t','Ʈ':'t','ʈ':'t','ȶ':'t',
'Ú':'u','ú':'u','Ù':'u','ù':'u','Ŭ':'u','ŭ':'u','Û':'u','û':'u','Ǔ':'u','ǔ':'u','Ů':'u','ů':'u','Ü':'u','ü':'u','Ǘ':'u','ǘ':'u','Ǜ':'u','ǜ':'u','Ǚ':'u','ǚ':'u','Ǖ':'u','ǖ':'u','Ű':'u','ű':'u','Ũ':'u','ũ':'u','':'u','':'u','Ų':'u','ų':'u','Ū':'u','ū':'u','':'u','':'u','':'u','':'u','Ȕ':'u','ȕ':'u','Ȗ':'u','ȗ':'u','Ư':'u','ư':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','':'u','Ʉ':'u','ʉ':'u',
'':'v','':'v','':'v','ṿ':'v','Ʋ':'v','ʋ':'v',
'':'w','':'w','':'w','':'w','Ŵ':'w','ŵ':'w','W':'w','̊':'w','':'w','':'w','':'w','':'w','':'w','':'w','':'w',
'':'x','':'x','':'x','':'x',
'Ý':'y','ý':'y','':'y','':'y','Ŷ':'y','ŷ':'y','Y':'y','̊':'y','':'y','Ÿ':'y','ÿ':'y','':'y','':'y','':'y','':'y','Ȳ':'y','ȳ':'y','':'y','':'y','':'y','':'y','ʏ':'y','Ɏ':'y','ɏ':'y','Ƴ':'y','ƴ':'y',
'Ź':'z','ź':'z','':'z','':'z','Ž':'z','ž':'z','Ż':'z','ż':'z','':'z','':'z','':'z','':'z','Ƶ':'z','ƶ':'z','Ȥ':'z','ȥ':'z','ʐ':'z','ʑ':'z','':'z','':'z','Ǯ':'z','ǯ':'z','ƺ':'z'
};
function accent_fold (s) {
if (!s) { return ''; }
var ret = '';
for (var i=0; i<s.length; i++) {
ret += accent_map[s.charAt(i)] || s.charAt(i);
}
return ret;
}
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.