Skip to main content
December 14, 2007
Answered

removing accents

  • December 14, 2007
  • 2 replies
  • 501 views
Hello,

I need some help manipulating a string to remove all possible accents to avoid server problems.

I have per example this "áçõê" and I need to have "acoe", but the string can also be "éàç", so I can't use the split("á"). I need to have a global function who can deal with all the accents at once.

Any sugestion?

Thanks
This topic has been closed for replies.
Correct answer BSpero-9w1iVb
Pluda,
Your code is actually ALMOST correct. Use "sem_pontos" in the repeat loop and trace that out, it should work. You keep resetting the variable over and over, while never manipulating the modified results. Just change the line:

2 replies

BSpero-9w1iVbCorrect answer
Inspiring
December 14, 2007
Pluda,
Your code is actually ALMOST correct. Use "sem_pontos" in the repeat loop and trace that out, it should work. You keep resetting the variable over and over, while never manipulating the modified results. Just change the line:

December 14, 2007
Hello BSpero, thanks for reply

yep, you're right, it works now

Many thanks man :-)
December 14, 2007
trying like this I got no result, I think inside a loop flash can't replace all at once.

how should I change this code?

Thanks

var o_que:String = "TESTÈ de AÇçentos à é ì í ó ã";
var lowercase:String = o_que.toLowerCase();
var sem_espacos:String = lowercase.split(" ").join("_");
var sem_pontos:String = sem_espacos.split(".").join("");
var acentos:Array = new Array("á","à","é","è","í","ì","ó","ò","ö","ő","ú","ù","ü","ű","ç");
var substituir:Array = new Array("a","a","e","e","i","i","o","o","o","o","u","u","u","u","c");
for (as=0; as<acentos.length; as++) {
var o_que_corrigido:String = sem_pontos.split(acentos[as]).join(substituir[as]);
}
trace(o_que_corrigido);