HTMLTrans(string)
Last updated August 28, 2003
Version: 2 | Requires: ColdFusion 5 | 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:
<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 added
DeMoronize
2 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)