CFLib.org – Common Function Library Project

HTMLTrans(string)

Last updated August 28, 2003

author

Oblio

Version: 2 | Requires: CF5 | Library: StrLib

Description:
This function is intended to obfuscate strings on a page. It converts characters to their ASCII decimal equivalent, and outputs the concatenated result in place of the original. This is particularly useful for protecting email addresses from harvesters (or at least until they figure it out). Best of all, you can still use href="mailto:#HTMLTrans(example)#".

Return Values:
Returns a string.

Example:

<cfset example="name@example.com">

<cfoutput>#HTMLTrans(example)#</cfoutput>

Parameters:

Name Description Required
string String to format. Yes

Full UDF Source:

/**
 * Converts the characters in a string to encoded special characters.
 * Rewritten by Raymond Camden
 * 
 * @param string 	 String to format. (Required)
 * @return Returns a string. 
 * @author Oblio (oleitch@locustcreek.com) 
 * @version 2, August 28, 2003 
 */
function HTMLTrans(string) {
	var slen = len(string);
	var encoded = "";

	while (slen) {
		encoded = encoded & "&##" & Asc(left(string,1)) & ";";
		string = mid(string,2,slen-1);
		slen=len(string);
	}
	return encoded;
}
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