Created
April 7, 2012 16:03
-
-
Save Godefroy/2329974 to your computer and use it in GitHub Desktop.
String prototype function to remove accents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.removeAccents = function(){ | |
var t = this, | |
a = { | |
'œ' : 'oe', | |
'Œ' : 'Oe', | |
'æ' : 'ae', | |
'Æ' : 'Ae', | |
'[ÀÁÂÃÄÅĀĂǍẠẢẤẦẨẪẬẮẰẲẴẶǺĄ]' : 'A', | |
'[àáâãäåāăǎạảấầẩẫậắằẳẵặǻą]' : 'a', | |
'[ÇĆĈĊČ]' : 'C', | |
'[çćĉċč]' : 'c', | |
'[ÐĎĐ]' : 'D', | |
'[ďđ]' : 'd', | |
'[ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ]' : 'E', | |
'[èéêëēĕėęěẹẻẽếềểễệ]' : 'e', | |
'[ĜĞĠĢ]' : 'G', | |
'[ĝğġģ]' : 'g', | |
'[ĤĦ]' : 'H', | |
'[ĥħ]' : 'h', | |
'[ÌÍÎÏĨĪĬĮİǏỈỊ]' : 'I', | |
'[ìíîïĩīĭįıǐỉị]' : 'i', | |
'Ĵ' : 'J', | |
'ĵ' : 'j', | |
'Ķ' : 'K', | |
'ķ' : 'k', | |
'[ĹĻĽĿŁ]' : 'L', | |
'[ĺļľŀł]' : 'l', | |
'[ÑŃŅŇ]' : 'N', | |
'[ñńņňʼn]' : 'n', | |
'[ÒÓÔÕÖØŌŎŐƠǑǾỌỎỐỒỔỖỘỚỜỞỠỢ]' : 'O', | |
'[òóôõöøōŏőơǒǿọỏốồổỗộớờởỡợð]' : 'o', | |
'[ŔŖŘ]' : 'R', | |
'[ŕŗř]' : 'r', | |
'[ŚŜŞŠ]' : 'S', | |
'[śŝşš]' : 's', | |
'[ŢŤŦ]' : 'T', | |
'[ţťŧ]' : 't', | |
'[ÙÚÛÜŨŪŬŮŰŲƯǓǕǗǙǛỤỦỨỪỬỮỰ]' : 'U', | |
'[ùúûüũūŭůűųưǔǖǘǚǜụủứừửữự]' : 'u', | |
'[ŴẀẂẄ]' : 'W', | |
'[ŵẁẃẅ]' : 'w', | |
'[ÝŶŸỲỸỶỴ]' : 'Y', | |
'[ýÿŷỹỵỷỳ]' : 'y', | |
'[ŹŻŽ]' : 'Z', | |
'[źżž]' : 'z' | |
}; | |
for(var i in a){ | |
t = t.replace(new RegExp(i, "g"), a[i]); | |
} | |
return t; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment