Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Character encoding problem with pound sign

Avatar

Level 2

Hi everyone,

 

We have implement a servlet which returns values in json format. The values are retrieved from an external api call and saved in crx/de, then filtered and returned in json format using a servlet. In the response any string that contains a pound sign is displayed as �. The character encoding of the response is set to 'utf-8'. We are using AEM 6.5.12. Any idea how we can fix this? Thank you.

3 Replies

Avatar

Level 5

@Mhatri  Can you try-

response.setContentType(ContentTypeUtil.TYPE_JSON);
response.setCharacterEncoding(CharEncoding.UTF_8);

Avatar

Level 2

Thank you for your response @manjunathdj . Content type and character encoding are set for the response but still getting the same issue.

Avatar

Community Advisor

Hi @Mhatri ,

I vividly remember, we were even facing similar issue for encoding such special characters. I would suggest to implement some custom logic to achieve the same.

Regards,

Santosh