How to get Charset - "windows-874 "
843834Dec 24 2007 — edited Dec 31 2007Hello,
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