#245

Uft-8 encoded scaml doesn't render right

    • Created on: Wed, Jun 01 2011 (12 months ago)
    • Reported by: valotas
    • Assigned to: -
    • Milestone: -
    • Estimate: None/Small/Medium/Large None
    • Status: New
    • Priority: Normal (3)
    • Component: scalate-core
    • Permission type: None
    Considering the template below:
    !!!
    %html
      %head
        %title Some title
    %body
      %p Some text in greek (Καλησπέρα)

    I can't get the greek work right. As I can see from the generated source code the greek characters was escaped, so I used = "Some text in greek (Καλησπέρα)" instead and the generated scala file did have the right characters. Still in both situations I can't get the template get rendered right (the output html contains ? instead of greek characters).

    I had similar problems with groovy and -Dfile.encoding=UTF-8 did solve the problem so I made sure this system property had UTF-8 as value.
  • Followers
     
    Ico-users valotas 
     
    Attachments
    No attachments
    Associations
     
    No associations
    Activity
     
    User picture

          on Sep 11, 2011 @ 06:04pm UTC * By valotas

    Ok, As I had some problems building scalate from source the last time I tried, I just subclassed the TemplateEngineFilter with something like:

    public class FixedScalateTemplateFilter extends TemplateEngineFilter {
      @Override
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
        response.setCharacterEncoding(request.getCharacterEncoding()); // Just fixed the character encoding!
        super.doFilter(request, response, chain);
      }
    }

    and solved the problem! In this case I could also just put response.setCharacterEncoding("UTF-8");, but I think that setting the response character encoding to the requested one should do the trick as in most cases we expect to have a response encoded just like the request.

    Am I the only one who has problems with encoding?
    Time Expenditure
    Loading