checkAsc(str [, denylist])
Last updated September 23, 2004
Version: 1 | Requires: ColdFusion 5 | 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 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:
<cfscript>
/**
* 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;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)