CFLib.org – Common Function Library Project

stripExtendedAscii(str)

Last updated August 30, 2011

author

Kevin Benore

Version: 2 | Requires: CF5 | 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:

USAGE:

<cfscript>stripExtendedAscii(VariableWithBadChars);</cfscript>

OR

<cfoutput>
#stripExtendedAscii(VariableWithBadChars)#
</cfoutput>

Parameters:

Name Description Required
str String to modify. Yes

Full UDF Source:

/**
 * 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)
};
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