3 Replies Latest reply on Oct 2, 2013 7:48 AM by Aegis Kleais

    ColdFusion Changing Spanish Characters

    RyanISD196 Level 1

      For some reason ColdFusion seems to be changing some spanish characters. I've narrowed it down to ColdFusion (or maybe IIS 6 scripting handler) because the text comes out fine on a plain .html file but simply changing it to .cfm causes the characters to come out incorrect. Any help would be great! Thanks

       

      FromHTML.png

      FromCF.png

      P.S. The screenshots above look far better when I'm editing this post vs viewing it, not sure what's going on there.

        • 1. Re: ColdFusion Changing Spanish Characters
          Aegis Kleais Level 3

          First, I would ensure that you are using the proper page encoding.  You can utilize headers or override it with the <cfprocessingdirective>.  I currently use utf-8.

           

          Secondly, how are you generating the characters?  Are you using their HTML entity codes?

           

          For example, to output: This is an A character with a grave: À

           

          You need to be generating:  <p>This is an A character with a grave: &agrave;</p>

           

          You can optionally use the entity code, like: <p>This is an A character with a grave: &##224;</p>  (Note the double # to ensure ColdFusion does not assume you wanted a variable/BIF there.

          • 2. Re: ColdFusion Changing Spanish Characters
            RyanISD196 Level 1

            I thought it was all UTF-8 as the response headers in Chrome said so. However, apparently ColdFusion was not processing as UTF-8 because the <cfprocessingdirective pageencoding="utf-8" /> tag did fix the issue. I had to place the tag in every page as it doesn't seem to work just in Application.cfc

             

            There was a secondary issue that I didn't explain here. I store the translated text in .json files. So when <cffile /> was reading the translations it wasn't using UTF-8 either. Adding the charset="utf-8" quickly solved that issue as well.

             

            Thanks for the help! I figured it would be something easy like that but didn't know where to start looking. This is our first translated app.

            • 3. Re: ColdFusion Changing Spanish Characters
              Aegis Kleais Level 3

              Very cool!  Glad I could help.  Internationalization, oh man, that's gonna be a fun challenge!

               

              I think ColdFusion has tons of great Locale-based functions to help ensure that it caters itself to the consumer as best it can.

               

              The <cfprocessingdirective> is usually used to encapsulate information that you want to modify whitespace or character encoding on, but are you using <cfcontent> without specifying the encoding anywhere?  Usually, CF outputs content encoded as UTF-8 (though it operates internally at UTF-16), but if a <cfcontent> is used at one point and doesn't specify the encoding, then CF is sometimes set to auto-determine the encoding.

               

              I'm not sure if setting a header from the server-side down is an option, or, if you could utilize a meta tag to do likewise.