/ Published in: ActionScript 3
remove diacritics with the possibility convert to lowercase
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function removeDiacritics(text:String, lowerCase:Boolean = false):String { var mapDi:String="áäà âÄçÄéěëèêÃïîĺľňóôöŕšťúůüùûýřžÃÄÀÂČÇĎÉĚËÈÊÃÃÎĹĽŇÓÔŒÖŔŠŤÚŮÜÙÛÃŘŽ"; var mapNo:String="aaaaccdeeeeeiiillnooorstuuuuuyrzAAAACCDEEEEEIIILLNOOSORSTUUUUUYRZ"; var strOut:String=""; lowerCase?text=text.toLocaleLowerCase():null; for (var i:uint = 0; i < text.length; i++) { if (mapDi.indexOf(text.charAt(i))!=-1) { strOut+=mapNo.charAt(mapDi.indexOf(text.charAt(i))); } else { strOut+=text.charAt(i); } } return strOut; }