I need to convert characters in French, Sweden and others language in their "normal" standard ASCII format.
I don't know how to explain, here's an example:
...
In bash Unix I would use iconv. How can I do in ColdFusion9 / Java?
I found this simple UDF at CFLib.org:
deAccent
<cfscript>
/**
* Replaces accented characters with their non accented closest equivalents.
*
* @return Returns a string.
* @author Rachel Lehman ([email protected])
* @version 1, November 15, 2010
*/
function deAccent(str){
var newstr = "";
var list1 = "á,é,í,ó,ú,ý,à,è,ì,ò,ù,â,ê,î,ô,û,ã,ñ,õ,ä,ë,ï,ö,ü,ÿ,À,È,Ì,Ò,Ù,Á,É,Í,Ó,Ú,Ý,Â,Ê,Î,Ô,Û,Ã,Ñ,Õ,Ä,Ë,Ï,Ö,Ü,x";
var list2 = "a,e,i,o,y,u,a,e,i,o,u,a,e,i,o,u,a,n,o,a,e,i,o,u,y,A,E,I,O,U,A,E,I,O,U,Y,A,E,I,O,U,A,N,O,A,E,I,O,U,Y";
newstr = ReplaceList(str,list1,list2);
return newstr;
}
</cfscript>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With