Skip to main content
Inspiring
August 23, 2010
Question

apostrophes

  • August 23, 2010
  • 3 replies
  • 4425 views

Hi,

I wrote some blogs for my site in notepad, then copy pasted it into word to spellcheck and grammar check, then I copy pasted it back into a notepad document then copy pasted that into my insert record form and everything looks OK in the form, but then when I look at it when its on the site, I see something like this for every apostraphe:

that¬タルs

is there some easy fix for this?

    This topic has been closed for replies.

    3 replies

    Inspiring
    September 29, 2010

    Wycks,

    Coldfusion does a good job of handling character encoding, but it requires a combination of tags.

    <cfprocessingdirective> - tells Coldfusion the character set to work with.  Also note that this has to be at the top of every template you want coldfusion to encode.

    <cfcontent type> - tells the browser the character set to work with.

    <meta http-equiv="Content-Type"> - html head entry to specify encoding.

    utf-8  -  this handles about 99% of the high ascii characters

    Example:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <cfprocessingdirective pageencoding="utf-8">
    <cfcontent type='text/html; charset=utf-8'>
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >

    </head>

    <cfquery name="qSearch" datasource="#database#" username="#dbid#" password="#dbpass#">
      SELECT  description
      FROM table
    </cfquery>

    <body>

    <cfoutput query="qSearch">

    #HTMLEditFormat(description)#

    </cfoutput>

    </body>

    </html>

    In my real world example, my users are copying data from Microsoft word, so I see the apostrophes, em dashes, etc, and this code has handled them without a hitch.

    Lastly, shout out to Eric Stevens where I learn this useful knowledge.  He has an interesting read on this topic here:

    http://www.bandeblog.com/2008/05/unicode-absolute-minimum-every.html

    Jeff Vaught

    Inspiring
    September 29, 2010

    One thing that a lot of people don't seem to get, and it seems it could be the case here too is that <cfprocessingdirective> is a compiler instruction (hence it needing to be in every file).  It's only relevant if the source code in the physical file is encoded in anything other than just plain ASCII text.  In your example file, there's nothing that's not just plain ASCII text, so one doesn't need the <cfprocessingdirective> tag.

    <cfprocessingdirective> is simply an instruction to the compiler as to how which encoding to load the source code as before compiling it; it is meaningless at runtime.  So it doesn't matter if your site serves DB data and processes form & URL data that's in a mix of Russian, Chinese and Arabic (and MS Word ;-)... if the source code is all plain ASCII text.

    It would only be relevant if your CFM files are encoded in UTF-8 (etc) format.  Which is seldom the case.

    --

    Adam

    Owainnorth
    Inspiring
    September 25, 2010

    Well that's an interesting point you make there hsdvkyoa, and I agree the rotational ability of Holy Wrath is not discussed nearly enough. Personally it's ability to damage everything whilst leaving demons and our good friends The Undead merely stunned impresses me no end, and don't even start me on some of the other mobs it can stun!

    Thanks for clearing up your delivery times as well, I meant to ask you about those - I've been meaning to pick up some RuneScape Gold for a while now, alas my local supermarket has been out of stock for weeks. I'll place an order later today, I assume I can just send you all my bank details and let you take care of the financials?

    Cfcaptcha anyone?

    ilssac
    Inspiring
    September 25, 2010

    Owain

    I presume your response was to some spam message that has since been removed.

    But I just to say, your message made me look at least three times to try an figure out how a message from one of my RPG forums got crossed with this ColdFusion forum. 

    Inspiring
    September 25, 2010

    Yep, I reported the thing that Owain replied to as spam, and it was duly removed.

    Owain, as excrutiatingly amusing as your reply was... there's a "report spam" option next to every message on these forums.  Please don't dignify spam messages with a reply, just report them and move along.

    --

    Adam

    Inspiring
    August 23, 2010

    MS Word is probably replacing plain text single quotes with smart quotes.  You will need to either replace the smart quotes with plain single quotes or remove them on the server side.

    You might find this blog post helpful.

    http://www.bennadel.com/blog/1155-Cleaning-High-Ascii-Values-For-Web-Safeness-In-ColdFusion.htm

    wycksAuthor
    Inspiring
    August 23, 2010

    Thanks for the link.

    The guy said how he used the: Replace() on FORM values... how specifically could I use that?  (what would that complete solution look like?)

    Inspiring
    August 23, 2010

    There is a sample user defined function by Ray Camden to handle this: http://www.coldfusionjedi.com/index.cfm/2006/11/2/xmlFormat-and-Microsofts-Funky-Characters

    You can call this function on each form field.