Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1214

UTF-8 encoding in java [closed]

$
0
0

I'm passing an arabic text as a payload to doPost servlet. while I'm retrieving the data from request object, I'm getting a Junk value instead of the original one.

Tried with the below code but still no luck. Any inputs would be helpful.

ObjectMapper mapper = new ObjectMapper();String requestBody = getPostBody(request);Map<String, String> requestMap = mapper.readValue(requestBody, Map.class);String fName = requestMap.get("firstName");   // Junk value getting herebyte[] bytes = fName.getBytes(StandardCharsets.UTF_8);String EncodedString = new String(bytes, StandardCharsets.UTF_8); // after encoding also getting    the same junk value

Viewing all articles
Browse latest Browse all 1214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>