Japanese text garbled while passing to a http restlet service
Posted
by satish-gunuputi
on Stack Overflow
See other posts from Stack Overflow
or by satish-gunuputi
Published on 2010-04-06T13:57:02Z
Indexed on
2010/04/06
14:03 UTC
Read the original article
Hit count: 555
japanese
Hi ,
I have a perl client which is calling a 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.
© Stack Overflow or respective owner