3 Replies Latest reply on Feb 17, 2012 12:11 AM by BKBK

    Convert ’ to an apostrophe

    plarts Level 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 :






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

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



      </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.

        • 1. Re: Convert ’ to an apostrophe
          plarts Level 1

          As I cannot update my question above, I add this : the original code from the XML code is :

          <title><![CDATA[Sven Yrvind : un ketch de 15 pieds à travers l’Atlantique !]]></title>


          If I take only : title=Sven Yrvind : un ketch de 15 pieds à travers l’AtlantiqueÂ

          and use : <cfset title=#replacenocase(title,'’',"'","all")#>

          Then it does work.


          The <![CDATA[   make this replacement not working.


          Thanks for any Help .

          • 2. Re: Convert ’ to an apostrophe
            plarts Level 1

            I found the solution,


            I did the replacement at the beginning :

            <cfhttp url="#xml_file#" method="GET">


            <cfset content=#CFHTTP.FileContent#>

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


            and not after the  XmlParse

            • 3. Re: Convert ’ to an apostrophe
              BKBK Adobe Community Professional & MVP

              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")>