querybuilder returning ISO-8859-1 instead of utf8 | Community
Skip to main content
Level 8
May 2, 2021 3:50 PM UTC
Solved

querybuilder returning ISO-8859-1 instead of utf8

I am using querybuilder to read the properties of some text components. If I enter UTF8 chars (e.g ü) into the Adobe author editor (and I can see from the page source that its set to UTF8), I get ISO-8859-1 out.

When I get the ValueMap from the component in a servlet, I write the results to a file, and to the servlet response writer also.  In the file, if I open it as a ISO-8859-1 I see ü. If i open it as a utf8 file (in VS code), i get a back "?".  In postman I see a black "?" and also on the resultant webpage (which has utf8 set in the header).

NOTE: we have set the servlet parameter encoding to UTF8 in the OSGi config as per: http://adobeaemtips.blogspot.com/2015/11/utf-8-encoding-in-aem.html

Any ideas?

FYI, I also tried with Content-Type: application/json; charset=utf-8 request header.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Asutosh_Jena_
Asutosh_Jena_Accepted solution
New Participant
May 2, 2021 4:56 PM UTC

Hi @tb3dock 

 

Please add the below entry in "Apache Sling Main Servlet" config and try.

 

Additional response headers:
                 Content-Type=text/html;charset=utf-8

 

Thanks!

7 replies

arunpatidar
New Participant
May 2, 2021 10:55 PM UTC

you can try escaping HTML character e.g.

org.apache.commons.lang.StringEscapeUtils.escapeHtml("aäuüöo");

 

Translate
Arun Patidar
Asutosh_Jena_
Asutosh_Jena_Accepted solution
New Participant
May 2, 2021 4:56 PM UTC

Hi @tb3dock 

 

Please add the below entry in "Apache Sling Main Servlet" config and try.

 

Additional response headers:
                 Content-Type=text/html;charset=utf-8

 

Thanks!

Translate
TB3dockAuthor
Level 8
May 2, 2021 8:48 PM UTC
Hi, thanks for the reply. do you mean osgi config, or the servlet source code? Setting the header probably wont have any effect, as the encoding is wrong right after reading it from the query builder result and logging it.
Translate