convertSpecialChars(str)
Last updated January 03, 2011
Version: 2 | Requires: CF5 | 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:
<CFSET STR = "?special? quotes?">
<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:
/**
* 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);
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016