I have a Map, LinkedHashMap, to be more precise. And I want to put a string object in it. And then I read this value to see what is actually stored. The string itself has non-ascii characters (Cyrillic, Korean, etc.). As soon as I put it on the card and then read it, these characters are replaced by. Some code:
Map obj = new LinkedHashMap();
System.out.println("name: " + getName());
obj.put("name", getName());
System.out.println("written stuff: " + obj.get("name"));
What is the trick here? I use this map to make a JSON object with json-simple and send it from the server to the client.
Update:
Wow, sorry for the whole mess. At first I blamed the datastore, and then the map, finally, as expected, it was my mistake elsewhere. I sent json data in the application settings content type as "application / json"
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
resp.setContentType("application/json");
resp.getWriter().println(jsonObj.toString());
}
UTF-8, , .
resp.setCharacterEncoding("UTF-8");
, UTF-8 , ascii.