CFLib.org – Common Function Library Project

FolderCheck(folder)

Last updated May 9, 2003

author

Mike Gillespie

Version: 1 | Requires: CF5 | Library: FileSysLib

Description:
This function will replace the characters in a string to be used for a folder name with acceptable character replacements. Will support high ascii chars and replace spaces with "_". Great way to keep folder names legal, especially when dealing with "international" characters.

Return Values:
Returns a string.

Example:

<cfoutput>
#foldercheck("Espa�ol and Fran�ais")#
</cfoutput>

Parameters:

Name Description Required
folder Name of folder. Yes

Full UDF Source:

/**
 * Will replace chars in a string to be used to create a folder with valid equivalent replacements
 * 
 * @param folder 	 Name of folder. (Required)
 * @return Returns a string. 
 * @author Mike Gillespie (mike@striking.com) 
 * @version 1, May 9, 2003 
 */
function foldercheck(folder) {
   var bad_chars="�,/,\,*,&,%,$,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�";
   var good_chars="A,-,-,-,-,-,-,A,A,A,A,A,A,C,D,E,E,E,E,I,I,I,I,N,O,O,O,O,O,U,U,U,U,Y,a,a,a,a,a,a,a,c,e,e,e,o,e,i,i,i,i,n,o,o,o,o,o,u,u,u,u,y,y,i";
   var scrubbed="";

   if(folder eq "") return "";
   return replace(replace(ReplaceList(trim(folder), bad_chars, good_chars)," ","_","all"),"'","","all");
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson