CFLib.org – Common Function Library Project

FolderCheck(folder)

Last updated May 09, 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");
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson