0

I am trying to write the Euro currency symbol on my page. It works perfect when I load the page, but when I make a partial update through AJAX the Euro symbol is not being loaded correctly. I tried 3 different approaches:

<h:outputText value="&euro;" />
<h:outputText value="&#x26;euro;" />
<h:outputText value="€" />

When loading the page, it works with the first approach. The results are the following:

€
euro;
€

When making a partial update with AJAX, none of them works correctly:

?
&euro;
€

Same result as above when implementing the filter described in Unicode input retrieved via PrimeFaces input components become corrupted

I spent an entire day trying to solve this. I appreciate any help.

Thanks, Douglas.

Community
  • 1
  • 1
DHansen
  • 225
  • 3
  • 13

1 Answers1

3

The answer which you found applies only to decoding of HTTP request parameters (the submitted form values). This is however not applicable in your case. You've clearly a problem with encoding of the HTTP response (the HTML/XML output generation).

The encoding of the HTTP response can be controlled in at least 2 ways:

  • The encoding as declared in <f:view encoding>, which defaults to UTF-8. This can also programmatically be set via ExternalContext#setResponseCharacterEncoding(), but this is normally not to be done by the JSF developer.
  • The encoding which is used to save the physical template file. This does actually not influence the encoding being used during generating the HTML/XML output, but it does influence how the characters are treated. If the template file is saved using a different encoding than the <f:view encoding>, such as ISO-8859-1, then the characters may end up like Mojibake.

In your particular case, provided that you didn't modify the <f:view encoding> (you would otherwise more likely have explicitly mentioned it in your question), then the most probable cause is that your template files are saved using the wrong encoding. This is in turn to be configured in the editor itself. If it's for example Eclipse, then you need to set it via Window > Preferences > General > Workspace > Text File Encoding.

enter image description here

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555