jueves, 27 de marzo de 2014

JavasScript: mostrar acentos

con esta funcion

function tildes_unicode(str){
 str = str.replace('á','\u00e1');
 str = str.replace('é','\u00e9');
 str = str.replace('í','\u00ed');
 str = str.replace('ó','\u00f3');
 str = str.replace('ú','\u00fa');

 str = str.replace('Á','\u00c1');
 str = str.replace('É','\u00c9');
 str = str.replace('Í','\u00cd');
 str = str.replace('Ó','\u00d3');
 str = str.replace('Ú','\u00da');

 str = str.replace('ñ','\u00f1');
 str = str.replace('Ñ','\u00d1');
 return str;
}

No hay comentarios:

Publicar un comentario