groovy
  1. groovy
  2. GROOVY-3231

SimpleTemplateEngine (internally) uses shell's encoding irrespectfully to the incoming reader encoding

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.7
    • Fix Version/s: None
    • Component/s: Templating
    • Labels:
      None
    • Environment:
      it's more apparent on Windows
    • Number of attachments :
      1

      Description

      It's discussed in http://www.nabble.com/forum/ViewPost.jtp?post=21058369&framed=y

      I had a UTF-8 template with non-latin content (Russian), Windows's default encoding is cp-1252 and template engine uses it on a certain stage, so non-latin characters can be broken and the resulting HTML ends up with garbage rather than Russian letters. See attachment for such a template.

      Here is Guillaume's analysis:

      After a quick examination, although the reader properly reads the
      content of the template, we then generate some Groovy script
      representing that template, and that template is transformed into an
      inputstream of bytes using the engine's shell's encoding to be fed to
      groovy classloader at some point.
      The problem is when we get the bytes of the script, we use the shell's
      encoding, and if none was provided (by means of CompilerConfiguration)
      then the default system encoding is being used. So your UTF-8
      characters are read as ISO something instead, hence the ugly
      characters you see.

        Activity

        Hide
        Soenke Sothmann added a comment -

        I have the same problem with utf-8 encoded file. Is there any progress on this issue?

        Show
        Soenke Sothmann added a comment - I have the same problem with utf-8 encoded file. Is there any progress on this issue?
        Hide
        CÚdric Champeau added a comment -

        As far as I know, this has been fixed in revision #17575. Can you post a snippet on how you use the template engine ?

        Show
        CÚdric Champeau added a comment - As far as I know, this has been fixed in revision #17575. Can you post a snippet on how you use the template engine ?

          People

          • Assignee:
            Unassigned
            Reporter:
            Yegor Bryukhov
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: