Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

apostrophes

Explorer ,
Aug 23, 2010 Aug 23, 2010

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?

4.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 23, 2010 Aug 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2010 Aug 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?)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 23, 2010 Aug 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2010 Aug 23, 2010

I'm looking through the book I'm trying to learn coldfusion from and the examples for functions and arguments aren't very good when it comes to what I need to do versus what they show me how to do... how exactly do I call that function/arugment for the form field?  Does that code you just gave me go in Application.cfc?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2010 Aug 23, 2010

lets say I modify the code to be like this:

<cffunction name="safeText" returnType="string" access="private" output="false">
2      <cfargument name="txt" type="string" required="true">
3
4      <cfset arguments.txt = replaceList(arguments.txt,chr(8216) & "," & chr(8217) & "," & chr(8220) & "," & chr(8221) & "," & chr(8212) & "," & chr(8213) & "," & chr(8230),"',',"","",--,--,...")>
5      <cfreturn CleanTxtFormat(arguments.txt)>
6 </cffunction>

would I call it like this:

#CleanTxtFormat(FORM.content)#

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 23, 2010 Aug 23, 2010

I recommend that you review the CF9 documentation.  You might include the cffunction definition in an include file which can be included on pages that required the function or place it within a ColdFusion component file.

"Writing and Calling User-Defined Functions"
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7ff3.html


You would call the function by using the name of the function.  This assumes a form field 'blogText' contains the text to be cleaned.
<cfset cleanBlogText=safeText(form.blogText)>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 23, 2010 Aug 23, 2010

I tried using this on my form and it doesn't fix it:

      <cffunction name="safeText" returnType="string" access="private" output="false">
     <cfargument name="txt" type="string" required="true">

     <cfset arguments.txt = replaceList(arguments.txt,chr(8216) & "," & chr(8217) & "," & chr(8220) & "," & chr(8221) & "," & chr(8212) & "," & chr(8213) & "," & chr(8230),"',',"","",--,--,...")>
     <cfreturn xmlFormat(arguments.txt)>
</cffunction>

<cfset cleanBlogText = safeText(FORM.blog_content)>

I've tried putting it in several places... where should it go?

am I not getting the code right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 24, 2010 Aug 24, 2010

Things to check:

1. Have you verified that the characters you need replaced are included in the safeText function?

2. Does the blog content look correct if Word is not used?

3. If you add the following line to the end of your sample does the output look correct? This should be tested with input copied from MS Word and include quotation marks.

#cleanBlogText#</cfoutput

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 26, 2010 Aug 26, 2010

I'm still having trouble, specifically with all my apostrophes showing up as question marks. and I'm getting the error "

Variable CLEANBLOGTEXT is undefined.

I'm trying to use this code:

<cffunction name="safeText" returnType="string" access="private" output="false">
      <cfargument name="txt" type="string" required="true">

     <cfset arguments.txt = replaceList(arguments.txt,chr(8216) & "," & chr(8217) & "," & chr(8220) & "," & chr(8221) & "," & chr(8212) & "," & chr(8213) & "," & chr(8230),"',',"","",--,--,...")>

</cffunction>
<cfset cleanBlogText = safeText(rsFeaturedBlog.blog_content)>
                          
<cfoutput>#cleanBlogText#</cfoutput>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 26, 2010 Aug 26, 2010

You have a function named safeText.

Inside that function you accept an argument named 'txt'.

You then modify that 'arguments.txt' variable with some string functions.

But you are no longer returning the modified string from the function!

Add

<cfreturn argumetns.txt>  just before the closing <cffunction> tag.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 26, 2010 Aug 26, 2010

I no longer get the error, so that fixed it.

There were a bunch of apostrophes that weren't question marks, but there were other places where there were--and I realized somehow, the txt file I was posting had question marks where apostrophes should be...

do you happen to know of a specific format I can use to save a word document as a txt file that won't have weird characters show up where things like apostrophes should be?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 26, 2010 Aug 26, 2010

You could change the format settings in MS Word.

http://office.microsoft.com/en-us/word-help/change-curly-quotes-to-straight-quotes-and-vice-versa-HA010173242.aspx#BM13

I reccommend that you clear the text when you create the blog entry on the server.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 26, 2010 Aug 26, 2010

Disregard this post.

ilssac has provided the correct response.

Message was edited by: JR "Bob" Dobbs Disregard this post.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 26, 2010 Aug 26, 2010

regarding your second question:

I spell/grammar checked in word (which i will never do again) by copying my blog that was written in notepad to word and then copying the revised blog from woird back to notepad and then from notepad into my form on the site... everything looks fine, until I look at the posted blog on the site and see the question marks instead of apostrophes.

also, I have tried saving the revised blog in word to different formats and that hasn't worked

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 26, 2010 Aug 26, 2010

Have you examined the blog text (which I assume is stored in a database) and examined the characters within? I suspect that double quotes, ASCII character 34 and single quotes, ASCII character 39 are replaced by Word with other characters. Have you verified this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 25, 2010 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 25, 2010 Sep 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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 25, 2010 Sep 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 29, 2010 Sep 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2010 Sep 29, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources