stringToAscii(str)
Last updated June 17, 2010
Version: 1 | Requires: ColdFusion MX | Library: CFMLLib
Description:
Pass me a string and I'll convert it into HTML-friendly ASCII characters.
Return Values:
Returns a string.
Example:
<cfdump var="#stringToAscii(str)#" />
Parameters:
| Name | Description | Required |
|---|---|---|
| str | String to parse. | Yes |
Full UDF Source:
<cfscript>
/**
* I convert a string to ASCII characters.
*
* @param str String to parse. (Required)
* @return Returns a string.
* @author Stephen Withington (steve@stephenwithington.com)
* @version 1, June 17, 2010
*/
function stringToAscii(str) {
var local = StructNew();
local.oldStr = '';
local.newStr = '';
if ( StructKeyExists(arguments, 'str') and IsSimpleValue(arguments.str) ) {
local.oldStr = arguments.str;
for ( local.i=1; local.i lte Len(arguments.str); local.i++ ) {
local.newStr = local.newStr & '#' & Asc(Left(local.oldStr,1)) & ';';
local.oldStr = RemoveChars(local.oldStr,1,1);
};
};
return local.newStr;
};
</cfscript>
Search CFLib.org
Latest Additions
Robby Lansaw added
getComponentProp...
3 day(s) ago
Dave Anderson added
iniToStruct
25 day(s) ago
Dave Anderson added
deDupeArray
25 day(s) ago
Richard added
dice
27 day(s) ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)