CFLib.org – Common Function Library Project

checkAsc(str[, denylist])

Last updated September 23, 2004

author

Tjarko Rikkerink

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Only allow the ASCII text characters (33 to 126) for a certain string, you can also give a list of character numbers for the characters you also want to deny in the string.

Return Values:
Returns a boolean.

Example:

<cfset str = "ci.rcle">
<cfset denylist = "44,46,59,64,124">
<cfoutput>
    #CheckAsc(str,denylist)#
</cfoutput>

Parameters:

Name Description Required
str String to check. Yes
denylist Additional list of codes to deny. No

Full UDF Source:

/**
 * Only allow ASCII text string.
 * 
 * @param str 	 String to check. (Required)
 * @param denylist 	 Additional list of codes to deny. (Optional)
 * @return Returns a boolean. 
 * @author Tjarko Rikkerink (tjarko@ditadres.com) 
 * @version 1, September 23, 2004 
 */
function checkAsc(str){ 
	var i = 1;
	var nr = "";
	var denylist = "";
		
	if(arrayLen(arguments) gte 2) denylist = arguments[2];
	while (i LTE len(str)) { 
		nr = asc(mid(str,i,1)); 
		if (nr LT 33 OR nr GT 126 OR listFind(denylist,nr)){
			return false;
		} 
		i = i + 1; 
	} 

	return true; 
}
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