6 Replies Latest reply on Nov 24, 2009 8:31 AM by plarts

    decode UTF-8 to ISO-8859-1

    plarts Level 1

      I am using the Google Maps API, it return in utf-8,

      so for some countries, caracters are wrong,

      My server is ISO-8859-1

       

      So, how to convert the result from utf-8 to iso-8859-1 ?

       

      I tried :

      <cfprocessingdirective pageEncoding="UTF-8">
      <cfcontent type="text/html; charset=UTF-8">
      <cfset setEncoding("URL", "UTF-8")>
      <cfset setEncoding("FORM", "UTF-8")>

       

      and

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

       

      No change. always the wrong caracters,

       

      Thanks for any help with this mess.

       

      Pierre.

        • 1. Re: decode UTF-8 to ISO-8859-1
          Jochem van Dieten Level 4

          But your ColdFusion is not necessarily using the same charset as your server.

           

          Which version of CF are you using? If you are using CF 5 or older, forget it. If later, it should work out of the box if you use the appropriate charset attributes everywhere. Can you explain a bit more about the processing code?

          • 2. Re: decode UTF-8 to ISO-8859-1
            injun [576871]

            Hi!

            Try this trick:

             

            <cfsript>
            s="your_text";
            chr_current="your_current_charset";
            chr_new="your_new_charset";
            
            c=createobject("java", "java.lang.String").init(s);
            convstring=createobject("java", "java.lang.String").init(c.getbytes(chr_current),chr_new).tostring();
            </cfscript>
            

             

             

            • 3. Re: decode UTF-8 to ISO-8859-1
              plarts Level 1

              I am using CF v7.

               

              My server and CF are ISO-8859-1.

               

              But I am using Google Maps API , which returns country names in UTF-8.

              I tried the Google Maps directives, with adding parameter eo=ISO-8859-1 in the Google Key <script>,

              same result.

               

              Then  I have to convert to ISO-8859-1 , at least in that page for country names.

              (I have a specific problem with Thailande, Google Maps returns :  Tha๏lande

              and in the data base it writes : tha&#3663 ;lande   (an Access database)

               

              I answer to injun [576871]  ,

               

              Diificult to insert that code, because I am in a JavaScript code already.

              So it will not accept <cfscript> again inside ? I will try.

               

              Thanks for any help.

              Pierre.

              • 4. Re: decode UTF-8 to ISO-8859-1
                plarts Level 1

                Thanks, I will try at end of day,

                I have a meeting right now.

                 

                Regard, Pierre.

                 

                ======================================

                Pl-Art - Pierre LARDE

                http://www.pl-arts.com

                Email : pierre@pl-arts.com

                Tel : 04 93 60 48 91

                Auberge de la Clue, 06850, St Auban

                • 5. Re: decode UTF-8 to ISO-8859-1
                  plarts Level 1

                  Hi,

                   

                  I tried it before the insert Query,

                  But I get the same value :

                   

                  Before : Tha๏lande

                  After : Tha๏lande

                   

                  here is the code :

                   

                   

                  What do you think of ?

                   

                  Thanks for all.

                  Pierre.

                   

                  ======================================

                  Pl-Art - Pierre LARDE

                  http://www.pl-arts.com

                  Email : pierre@pl-arts.com

                  Tel : 04 93 60 48 91

                  Auberge de la Clue, 06850, St Auban

                  • 6. Re: decode UTF-8 to ISO-8859-1
                    plarts Level 1

                    I answered by mail, and the code has not appeared

                    .

                    here is the code used :

                    <cfoutput>
                    before : #form.pays#<br>
                    <cfscript>
                    s="#form.pays#";
                    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();
                    </cfscript>
                    after : #convstring#<br>
                    </cfoutput>

                     

                    Thanks for any help.

                    Pierre.