By default, you cannot post strings to AEM that contain special characters. For example, you cannot run this CURL command to post special characters to AEM.
curl -H "charset=utf-8" -u admin:admin -X POST --data "test=€ , Š , Œ , ™ , š , œ , ž" http://localhost:4502/content/mynodetest
If you attempt this command with CURL, wrong characters are inserted into AEM. That is, you will see: "Ç , è , î , Ö , Ü , £ , P , Ä , " instead of "€ , Š , Œ , ™ , š , œ , ž , Ž , Ÿ".
To successfully post special characters to AEM and use them to set node values in the AEM JCR, you have to create a custom Sling Servlet that is able to handle UTF-8 (UCS Transformation Format—8-bit) encoded strings. This encoding type is a variable-width encoding that represents every character in the Unicode character set.
The Sling Servlet can decode the strings that contain special characters using Java application logic.
String id = java.net.URLDecoder.decode(request.getParameter("id"), "UTF-8");
String firstName = java.net.URLDecoder.decode(request.getParameter("firstName"),"UTF-8");
To post these special characters to the AEM Sling Servlet, encode the strings, as shown in this Java code example.
String val = java.net.URLEncoder.encode("cust®", "UTF-8");
String firstName = java.net.URLEncoder.encode("TOM®", "UTF-8");
To read this development article, click, http://helpx.adobe.com/experience-manager/using/post_chars.html.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.