Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Reading chinese chars using valumap prop.get adding ?????

Avatar

Community Advisor

Hi Everyone,

 

Need help in reading some specific chinese chars from JCR repo.

I have one dialog where author enters content and save the page. Author created page for China and entered some content specific to China in the dialog and saved it. 

 

When I try to read the below content from JCR it is adding ???? . I have tried adding utf-8 still not able to get the specific content.

 

String mDesc = properties.get("messageDescription", String.class);

result :<p>?????</p>

 

annyreddy_0-1600799042620.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Anny0505,

If you are using Coral UI 3 textfield(granite/ui/components/coral/foundation/form/textfield) for your messageDescription field, try the solution highlighted in below article. 

Setting utf-8 in hidden resource (Solution A) - https://helpx.adobe.com/experience-manager/kb/utf-characters-not-stored-or-displayed-properly-after-...

Also, check if UTF-8 is set at page component level (via meta tag in head section of a page)

View solution in original post

5 Replies

Avatar

Community Advisor

If you're on latest version on AEM, you should not see this issue.

Try below approaches:

1. Make sure Default encoding is set to: utf-8 on Apache Sling Request Parameter Handling config. 

2. Try below and see if it works:

     String paramValue = "yourString";

     byte[] bytes = paramValue.getBytes(StandardCharsets.ISO_8859_1);

     paramValue = new String(bytes, StandardCharsets.UTF_8);

 

Let me know if it works or not.

 

Thanks,

Singaiah

Avatar

Community Advisor

Thnak you Singaiah. Still it did not work

annyreddy_0-1600802120296.png

 

Avatar

Correct answer by
Community Advisor

Hi @Anny0505,

If you are using Coral UI 3 textfield(granite/ui/components/coral/foundation/form/textfield) for your messageDescription field, try the solution highlighted in below article. 

Setting utf-8 in hidden resource (Solution A) - https://helpx.adobe.com/experience-manager/kb/utf-characters-not-stored-or-displayed-properly-after-...

Also, check if UTF-8 is set at page component level (via meta tag in head section of a page)

Avatar

Community Advisor

Thank you @ Vijayalakshmi_S.

 

Actually When I save the dialog data saving correctly as shown in below. I need to read the data from publish instance and send it to some third party application. I have implemented listener to get the latest activated page content and reading data from the valueMap.

when I use  String mDesc = properties.get("messageDescription", String.class);  content converting to ?????.

Is there any other way to read this content? 

 

annyreddy_0-1600826495003.png

 

 

I Also went through the article and followed same steps no luck

Avatar

Community Advisor

Can you share your snippet of where exactly you are retrieving the value map object and hence messageDescription field and where you are seeing "???" characters?

I tried using chinese characters in textfield of my component dialog -> backed by Sling model (@ValueMapValue with getter for the same) -> Printing the value in HTL from the model using the same getter -> It displays fine on the page.