stripExtendedAscii(str)
Last updated August 30, 2011
Version: 2 | Requires: ColdFusion 5 | Library: CFMLLib
Description:
Removes all extended and non-printing ASCII characters for a string. For example you may have data that has TABs, LINE FEEDs (or CARRIAGE RETURNs), international letters, or non-printing characters that you simply want to remove, this function will delete them.
Return Values:
Returns a string.
Example:
<cfscript>stripExtendedAscii(VariableWithBadChars);</cfscript>
OR
<cfoutput>
#stripExtendedAscii(VariableWithBadChars)#
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| str | String to modify. | Yes |
Full UDF Source:
<cfscript>
/**
* Removes all extended and non-printing ASCII characters from a string.
* v2 by Adam Cameron
*
* @param str String to modify. (Required)
* @return Returns a string.
* @author Kevin Benore (Kevin@Benore.net)
* @version 2, August 30, 2011
*/
function stripExtendedAscii(str) {
return reReplace(arguments.str, "[^\x20-\x7E]", "", "ALL"); // 0x20 = space, chr(32); \0x7E = ~ / tilde, chr(126)
};
</cfscript>
Search CFLib.org
Latest Additions
Robby Lansaw added
getComponentProp...
3 day(s) ago
Dave Anderson added
iniToStruct
25 day(s) ago
Dave Anderson added
deDupeArray
25 day(s) ago
Richard added
dice
27 day(s) ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)