convertSpecialChars(str)
Last updated January 3, 2011
Version: 2 | Requires: ColdFusion 5 | Library: StrLib
Description:
The function is useful for filtering out chars that may not display correctly when viewed in a text only format.
Currently it converts open and close quotes to
a normal qoute and converts slanted single quotes to normal single quotes
Return Values:
Returns a string.
Example:
<CFOUTPUT>
#STR# is converted to
#ConvertSpecialChars(STR)#
</CFOUTPUT>
<I>You may need to "View Source" to see the changes.</I>
Parameters:
| Name | Description | Required |
|---|---|---|
| str | The string to modify. | Yes |
Full UDF Source:
<cfscript>
/**
* Reformats special chars typically found when copying and pasting from Word.
* v2 by James Moberg
*
* @param str The string to modify. (Required)
* @return Returns a string.
* @author Glen Salisbury (gsalisbury@collegepublisher.com)
* @version 2, January 3, 2011
*/
function ConvertSpecialChars(textin) {
var bad = "#chr(145)#,#chr(146)#,#chr(147)#,#chr(148)#,#chr(151)#,#CHR(8217)#,#CHR(8216)#,#chr(188)#,#chr(189)#,#chr(190)#,#chr(174)#,#chr(173)#,#chr(169)#,#chr(160)#,#chr(153)#,#chr(150)#,#chr(149)#,#chr(133)#,#CHR(8220)#,#CHR(8221)#";
var good = "',',"","",-,',',1/4,1/2,3/4,(R),-,(C), ,TM,--,*,...,"",""";
return ReplaceList(textin, bad, good);
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
11 day(s) ago
Will Belden added
longTime
17 day(s) ago
James Sleeman added
quickSort
27 day(s) ago
Ben Forta added
GetHostAddress
30 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)