magicQuote(txt)
Last updated May 01, 2006
Version: 1 | Requires: CF5 | Library: StrLib
Description:
Accepts a single string and converts any straight typewriter quotes into their corresponding curly typographer's quotes to give a better visual appearence. Note, however, that this code assumes that the text passed in is plain text and not HTML.
Return Values:
Returns a string.
Example:
<cfoutput>#MagicQuote("""It's working?""")#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
txt | Text to format. | Yes |
Full UDF Source:
/**
* Cleanly converts typewriter quotes to typographer's quotes.
*
* @param txt Text to format. (Required)
* @return Returns a string.
* @author Keith Gaughan (kmgaughan@eircom.net)
* @version 1, May 1, 2006
*/
function magicQuote(txt) {
// Left quotes
txt = REReplace(txt, "(^|[ " & Chr(9) & Chr(10) & Chr(13) & "'])""", "\1&##8220;", "ALL");
txt = REReplace(txt, "(^|[ " & Chr(9) & Chr(10) & Chr(13) & "]|&##8220;)'", "\1&##8216;", "ALL");
// Right quotes
txt = Replace(txt, """", "&##8221;", "ALL");
txt = Replace(txt, "'&##8220;", "'&##8221;", "ALL");
txt = Replace(txt, "'", "&##8217;", "ALL");
return txt;
}
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