Encoding for Thymeleaf template files

Enonic version: 6.0.0
OS: Windows 8.1

Lots of questions popping up when trying out Enonic XP for the first time it seems…

I wasn’t able to find any information about this in the documentation. It seems that if I save my template files with UTF-8, the encoding gets mangled on the way to the rendered page and Norwegian characters end up as their typical “read as ISO” counterparts. It seem Enonic XP is assuming the template files are ISO-8859-1, as using this encoding when saving fixes all the Norwegian characters.

Is it possible to define somewhere that my thymeleaf .html template files are saved as UTF-8? Are you actually requiring template files to be saved in iso-8859-1 or has this something to do with some java setting on my machine?

:heart: UTF-8 :heart:

– Espen

1 Like

Hi Espen

It works fine with UTF-8 in all our tests.
It might be that your JVM has ISO-8859-1 as default encoding.
Can you test executing the following line in the command prompt, before you start XP?

set "JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF8"
1 Like

Thanks! Looks like that fixed the problem. I added the parameters to the setenv.bat used by server.bat so it gets added to the command line when starting Enonic XP.

Not sure what the best practice is when reading from file system resources, but there should probably be a note about this in the docs at least. Encoding can be such a hassle… :sob:

Good idea Espen - I’ll get this into our next release…