xmlFormat2(inString)
Last updated January 12, 2004
Version: 1 | Requires: ColdFusion 5 | Library: StrLib
Description:
xmlFormat2() can be used in place of xmlFormat() and will provide for a safer replacement including characters not caught by xmlFormat.
Return Values:
Returns a string.
Example:
<cfoutput>
<pre>
#xmlFormat(s)#
#xmlFormat2(s)#
</pre>
</cfoutput>
(view generated source)
Parameters:
| Name | Description | Required |
|---|---|---|
| inString | String to format. | Yes |
Full UDF Source:
<cfscript>
/**
* Similar to xmlFormat() but replaces all characters not on the "good" list as opposed to characters specifically on the "bad" list.
*
* @param inString String to format. (Required)
* @return Returns a string.
* @author Samuel Neff (sam@serndesign.com)
* @version 1, January 12, 2004
*/
function xmlFormat2(inString) {
var goodChars = "!@##$%^*()0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~[]{};:,./?\| -_=+#chr(13)##chr(10)##chr(9)#";
var i = 1;
var c = "";
var s = "";
for (i=1; i LTE len(inString); i=i+1) {
c = mid(inString, i, 1);
if (find(c, goodChars)) {
s = s & c;
} else {
s = s & "#" & asc(c) & ";";
}
}
return s;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
3 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)