CFLib.org – Common Function Library Project

Is7bit(text)

Last updated August 28, 2003

author

Vaughan Allan

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Determines whether a string is 7bit. Useful for guessing if a string contains binary data (after reading a file using cffile for example).

Return Values:
Returns a boolean.

Example:

<CFSET str1 = "The mat sat on the cat.">
<CFSET str2 = "The mat sat on the c" & chr(225) & "t.">
<CFIF Is7bit(str1)>
    Str1 is 7 bit.<br>
</CFIF>
<CFIF Is7bit(str2)>
    Str2 is 7 bit.<br>
</CFIF>

Parameters:

Name Description Required
text String to check. Yes

Full UDF Source:

/**
 * Determines whether a string is 7bit
 * Rewritten by Ray Camden
 * 
 * @param text      String to check. (Required)
 * @return Returns a boolean. 
 * @author Vaughan Allan (vorn@__nospam__vorn.org) 
 * @version 1, August 28, 2003 
 */
function Is7bit(text) {
    if(REFind("[\x80-\xFF]",text)) return false;
    return true;    
}

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