HTML encoding character issue

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

HTML encoding character issue

Alexandre
Hello,

I've some trouble to display characters wich are encoded in HTML format like é.
It happens since I updgraded to 2.1.4.RELEASE.
Before that my project was running with the 2.0.15.

Here's my problem:
I have a messages.properties containing this property -> my.text = caf&eactue;

In my HTML file I do this :
<p th:text="#{my.text}"></p>

When I access to my webpage the text is displayed like this :
"caf&eactue;" instead of "café"

Thanks in advance for your answers
Reply | Threaded
Open this post in threaded view
|

Re: HTML encoding character issue

Zemi
Administrator
Hello,

make sure you don't have a typo there, it should be eacute instead of eactue

Regards,
  Zemi

Reply | Threaded
Open this post in threaded view
|

Re: HTML encoding character issue

Alexandre
Hello Zemi,

Thanks for your answer.
Well in my file I don't have the typo so no, it's another problem...
Reply | Threaded
Open this post in threaded view
|

Re: HTML encoding character issue

Zemi
Administrator
Hi again,

I am not aware of a change in the behaviour of this, but from version 2.1.3 Thymeleaf is handling HTML entities using unbescape library, maybe the escaping issue is related. You could try version 2.1.2 to see it this is the reason.

Anyway, maybe this is the expected behaviour, as the ampersand character must be escaped in HTML. If you don't want it to be escaped you could use th:utext.

Other option is not to use the HTML entity in your properties file but the unicode escaping, like \u00c9 (I thinks most IDE will do this automatically for you).

Regards,
   Zemi

Reply | Threaded
Open this post in threaded view
|

Re: HTML encoding character issue

danielfernandez
Administrator
That is indeed the expected behaviour, but 2.0.x wasn't escaping your text because of a bug. One of the reasons Unbescape was developed was precisely to fix all these escaping-related bugs in 2.0.

If you want your code to go unchanged from your properties to your output, you should use th:utext.

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|

Re: HTML encoding character issue

Alexandre
This post was updated on .
Thank you guys for your help.
I think I'm gonna have a bit less work if I choose to convert my HTML encoded characters in ASCII.
Maybe I'm gonna use native2ascii maven plugin or ResourceBundle Editor.

Regards,
Alexandre