Posted By

hejaaa on 10/19/11


Tagged

remove diacritics


Versions (?)

Remove diacritics


 / Published in: ActionScript 3
 

remove diacritics with the possibility convert to lowercase

  1. function removeDiacritics(text:String, lowerCase:Boolean = false):String {
  2. var mapDi:String="áäàâčçďéěëèêíïîĺľňóôöŕšťúůüùûýřžÁÄÀÂČÇĎÉĚËÈÊÍÏÎĹĽŇÓÔŒÖŔŠŤÚŮÜÙÛÝŘŽ";
  3. var mapNo:String="aaaaccdeeeeeiiillnooorstuuuuuyrzAAAACCDEEEEEIIILLNOOSORSTUUUUUYRZ";
  4. var strOut:String="";
  5. lowerCase?text=text.toLocaleLowerCase():null;
  6. for (var i:uint = 0; i < text.length; i++) {
  7. if (mapDi.indexOf(text.charAt(i))!=-1) {
  8. strOut+=mapNo.charAt(mapDi.indexOf(text.charAt(i)));
  9. } else {
  10. strOut+=text.charAt(i);
  11. }
  12. }
  13. return strOut;
  14. }

Report this snippet  

You need to login to post a comment.