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
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while 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)