1

I have got the following main Controller default action in fw/1 (framework one 4.2), where i define some rc scope variables to be displayed in views/main/default.cfm.

main.cfc

 function default( struct rc ) {

        rc.name="ΡΨΩΓΔ";
        rc.dupl_name="üößä";
    } 

views/main/default.cfm

       <cfoutput>
    <p> #rc.name# </p>
    <p> #rc.dupl_name# </p>
      </cfoutput>

and finally in layouts/default.cfm

<cfoutput><!DOCTYPE html>
    <html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>
            A Simple FW/1 Layout Template
        </title>
    </head>
    <body>
       #body# 
    </body>
    </html>
</cfoutput>

Unfortunately i receive the following output

ΡΨΩΓΔ

üößä

Any idea that could help me?

Regards

asimkon
  • 915
  • 1
  • 14
  • 21
  • Looks like you have an char encoding issue? Is the file and the web encoding set properly as utf-8? Save that file with UTF-8 encoding and try again – AndreasRu Apr 06 '21 at 08:24
  • I have edited and saved them via Sublime Text 3 (Save with Encoding UTF-8). Regards – asimkon Apr 06 '21 at 08:34
  • 1
    Check if your servlet engine is using the correct charsets (e.g. Lucee in Adminisitrator » Settings » Charset » Web charset and Settings » Charset » Resource charset. Also look if your fronted http server is not sending conflicting charsets server header response (e.g. Content-Type: text/html;charset=...) What cfengine are you using? – AndreasRu Apr 06 '21 at 11:00
  • Yes, i just checked them and found that Web charset = UTF-8, template charset=windows-1252 (ANSI) and resource charset =windows-1252 (ANSI). I changed them all and now it works like a charm. A big thank you!!! – asimkon Apr 06 '21 at 13:59

1 Answers1

1

Because I already gave you a solution within my comments, I’m posting it as an answer here, so that others with similar issues may find the root of their charset issues.

The issue described above is very often the result of conflicting charset encodings. For example, if you are reading an ISO-8859-1 encoded file and outputting it with UTF8 without having them converted (de-/encoded) properly.

For the purpose of sending characters through a webapp as you are doing, the most common charset encoding as of today is UTF-8.

All you need to do is to harmonize characterset encodings or at least ensure that the encodings are set in such a manner that the processing engine is able to encode and decode the charsets correctly. What you can do in your case is:

  1. Verify the encoding of the template .cfm file and make sure it’s saved as UTF-8
  2. Define UTF-8 as your web charset in Lucee Administrator » Settings » Charset » Web charset
  3. Define UTF-8 as your ressource charset in Lucee Administrator » Settings » Charset » Resource charset.
  4. Make sure there are no other places where charset encodings are incorrectly set, such as a http server response header of “content-type: text/html;charset...” or a html meta-tag with a charset directive.
  5. If you have other type of ressources, such as a database, then you may need to check those also (connection and database/table settings).

Note: That charset doesn’t always have to be UTF-8 (UTF-8 might use multiple bytes for certain characters). There may be use cases you would achieve the same result with single byte encodings, such as ISO-8559-1, that would also need less computing ressources and less payload.

I hope this may help others with similar issues.

AndreasRu
  • 1,053
  • 8
  • 14