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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to get Charset - "windows-874 "

843834Dec 24 2007 — edited Dec 31 2007
Hello,

I am developing a mail client where User can change charset for viewing the email.(Just like outlook does).
This is some times required if charset information in not present in body part headers.

For Thai email, charset used is windows-874

When i try to create instance of Charset object using Charset.forName("windows-874"), it throws java.nio.charset.UnsupportedCharsetException exception.

Following is code -

byte []input ="� 3586 0E02 THAI CHARACTER KHO KHAI".getBytes();

Charset charset = Charset.forName("windows-874");

CharsetDecoder decoder = charset.newDecoder();
try {
ByteBuffer bbuf = ByteBuffer.wrap(input);
CharBuffer cbuf = decoder.decode(bbuf);
String s = cbuf.toString();
System.out.println(s);
} catch (CharacterCodingException ex) {
System.out.println(ex);
}

My question is, if MIME has charset set to windows-874, JavaMail works fine. But if i try to create instance of same charset it throws exception. Am i missing something?

Thanks,
~Advait
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 28 2008
Added on Dec 24 2007
1 comment
459 views