Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Decoding the content (text/plain) for charset "iso-2022-jp"

838162Feb 9 2011 — edited Feb 14 2011
Hi there,

I am using IMAP protocol to receive new email message and retrieving the contents using java mail API InputStream is = p.getInputStream()

The part content type is text/plain and text/html and charset is "iso-2022-jp"

The contents contain Japanese Characters as well. In my code, I am decoding the contents using charset "iso-2022-jp" to get the actual content (verified by sending the same content using SFTP client built on java mail APIs). The contents are decoded properly in Linux OS but not working properly on Windows OS.

Can anybody help me out the root cause of this problem? The code snippet is as follows

InputStream is = p.getInputStream();// p is Part object

byte[] bytesJap = IOUtils.toByteArray(is); // org.apache.commons.io.IOUtils

String decodedBytesJap = decodeBytes(charset, bytesJap);

The content I am getting while deploying the program
on Linux box:
-----------------------------------------
Subject: FW: Japanese characters

聖書に示された神の純粋なみ言葉に基づいて

----------------------------------------------
on Windows box:
-----------------------------------------
Subject: FW: Japanese characters

$B@;=q$K<($5$l$??@$N=c?h$J$_8@MU$K4p$E$$$F(B&

----------------------------------------------
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2011
Added on Feb 9 2011
7 comments
808 views