I have a Perl client which is calling an http restlet service (put method). Some of the parameters in this call contain japanese text. When I printed the contents of these request parameters in the restlet service I found these chars garbled !
This is my PERL client code:
my %request_headers = (
'DocumentName' => $document_name, --> This name is a JAPANESE String
'DocumentDescription' => 'Test Japanese Chars',
'content-length' => 200,
'Content-Type' => 'application/octet-stream; charset=utf-8',
'User-Agent' => "JPCharTester",
);
$s->write_request('PUT', '/test-document/TEST/TEST_DOCUMENT' , %request_headers, $content);
in this call both the values of $context and $document_name are JAPANESE Strings. But ONLY the document_name is received as garbled in my backend service.
Here goes the Service code:
String URL_ENCODING = "UTF-8";
String documentName = requestHeaders.getFirstValue("DocumentName");
System.out.println("Encoded Document Name : "+documentName+" <<<"); --> documentName is garbled here
try {
documentName = URLDecoder.decode(documentName, URL_ENCODING);
System.out.println(>>> Decoded Document Name : "+documentName+" <<<"); --> documentName is garbled here
} catch (java.io.UnsupportedEncodingException ex) {
throwException(ex.getMessage(), Status.SERVER_ERROR_INTERNAL, ex);
}
both the above log statements printed GARBLED TEXT !!
Can someone tell me what is the mistake I am doing and how to fix this ?
Thanks in advance for your help.
Regards, Satish.