CFLib.org – Common Function Library Project

deAccent()

Last updated November 15, 2010

Version: 1 | Requires: ColdFusion 5 | Library: CFMLLib

 
Rated 3 time(s). Average Rating: 5.0

Description:
Replaces accented characters in a string with their closest non-accented equivalent, such as French, Spanish and German vowels. Useful when creating filenames, etc. from people's names.

Return Values:
Returns a string.

Example:

view plain print about
<cfoutput>#deAccent('Pérez')#</cfoutput>

Parameters:

No arguments.

Full UDF Source:

view plain print about
<cfscript>
/**
 * Replaces accented characters with their non accented closest equivalents.
 * 
 * @return Returns a string. 
 * @author Rachel Lehman (raelehman@gmail.com) 
 * @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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson