Skip navigation
Currently Being Moderated

Convert ’ to an apostrophe

Feb 15, 2012 10:53 AM

Tags: #utf-8 #iso-8859-1 #’ #’

From an XML , the curly apostrophe is rendered as : ’, and displayed as ? (unknown)

because my server and Cf are in ISO--8859-1.

 

As this is an included file,

I cannot use the tags :

<cfprocessingdirective pageEncoding="UTF-8">

<cfcontent type="text/html; charset=UTF-8">

 

I only needs it for a small piece of text dipslayed. Not the whole page.

 

I searched for hours, I did not find any solution to convert the ’ to a single apostrophe.

I tried :

<cfset title=#replacenocase(title,'’',"'","all")#>  does not do anything.

I tried :

<cfscript>

          s="#title#";

          chr_current="UTF-8";

          chr_new="ISO-8859-1";

          

          c=createobject("java", "java.lang.String").init(s);

          convstring=createobject("java", "java.lang.String").init(c.getbytes(chr_current),chr_new).tostring();

        

          title=convstring;

</cfscript>  does not do anything.

I tried :

<cfset title=#replacenocase(title,"’","'","all")#> does not do anything. Because the char found is : ’

 

Thanks for any help.

 

More general question is :

How to convert a piece of text from UTF-8  to  ISO--8859-1 ?   not the whole page, because text coming from the DB is

stored as  ISO--8859-1.

 
Replies
  • Currently Being Moderated
    Feb 17, 2012 12:11 AM   in reply to plarts

    plarts wrote:

     

    <cfset content=#CFHTTP.FileContent#>

    <cfset content=#replacenocase(content,"’","'","all")#>

    This suggesion adds nothing to the discussion, but will make your code neater and more maintainable:

     

    <cfset content=CFHTTP.FileContent>

    <cfset content=replacenocase(content,"’","'","all")>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points