CFLib.org – Common Function Library Project

HTMLTrans(string)

Last updated August 28, 2003
Download UDF

author

Oblio                                             Oblio

Version: 2 | Requires: ColdFusion 5 | Library: StrLib

 
Rated 0 time(s). Average Rating: 0

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:

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

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
2 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson