4
I have a javascript code to remove accents, it works with any accent, less with the crase, and the code should work with the crase as well. I can’t find the bug.
var teste = "Çaptúra de Tela 2016-04-27 às 18.21.24.png à à";
function removerAcentos( s ) {
var map={"â":"a","Â":"A","à":"a","À":"A","á":"a","Á":"A","ã":"a","Ã":"A","ê":"e","Ê":"E","è":"e","È":"E","é":"e","É":"E","î":"i","Î":"I","ì":"i","Ì":"I","í":"i","Í":"I","õ":"o","Õ":"O","ô":"o","Ô":"O","ò":"o","Ò":"O","ó":"o","Ó":"O","ü":"u","Ü":"U","û":"u","Û":"U","ú":"u","Ú":"U","ù":"u","Ù":"U","ç":"c","Ç":"C"};
console.log('remove acentos',s.replace(/[\W\[\] ]/g,function(a){return map[a]||a}));
return s.replace(/[\W\[\] ]/g,function(a){return map[a]||a});
}
console.log(removerAcentos(teste));