What type of content would cause this exception?
Caused by: java.io.UnsupportedEncodingException: cp932
at sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:71)
at java.io.InputStreamReader.<init>(InputStreamReader.java:100)
at com.google.code.com.sun.mail.handlers.text_plain.getContent(text_plain.java:109)
at com.google.code.javax.activation.DataSourceDataContentHandler.getContent(DataHandler.java:803)
at com.google.code.javax.activation.DataHandler.getContent(DataHandler.java:550)
at com.google.code.javax.mail.internet.MimeBodyPart.getContent(MimeBodyPart.java:639)
And why can't OpenJDK handle this encoding?
Any text or text-based content that uses that character set / encoding!
According to Wikipedia, CP932 is an extension of Shift JIS ... which is one of the character sets that is used to represent Japanese text.
According to this page, CP932 is in the "Extended Encoding Set (contained in lib/charsets.jar)". If it is not in your install of OpenJDK, look for a yum / apt / whatever OpenJDK package that offers extra Java character set support. Support for CP932 in OpenJDK is definitely available somewhere ...
It is also possible (though IMO unlikely) that OpenJDK doesn't recognize "cp932" as an alias for what it refers to as "MS932" and "windows-31j".
I checked the code.
The issue is that Java (not just OpenJDK!) does not recognize the "cp932" alias at all. The reason it doesn't recognize it is that the alias is non-standard.
The official (IANA endorsed) name for this encoding is "windows-31j", and Java also supports the following aliases by default:
If you set the "sun.nio.cs.map" system property (i.e. using "-D...") to "Windows-31J/Shift_JIS", then Java will also recognize "shift-jis", "ms_kanji", "x-sjis", and "csShiftJIS" as being equivalent ... but this should only be used for backwards compatibility with old (1.4.0 and earlier) JDKs that didn't implement the real SHIFT-JIS encoding correctly. (Besides, this doesn't solve your problem ...)
So what can you do?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With