Getting "java.io.UnsupportedDencodingException: cp932"

Solution Unverified - Updated -

Environment

  • JBoss Enterprise Application Platform(EAP)
    • 6.1.x
    • openjdk 1.7.0_19

Issue

  • Application receive error "java.io.UnsupportedEncodingException: cp932" when accessing Japanese chars.

Resolution

a) Basically,The openjdk 1.7.0_19 does not recognize the "cp932" alias.

b) The official (IANA endorsed) name for this encoding is "windows-31j" follow url [1] and Java supports the following aliases by default:

1) MS932
2) windows-932
3) csWindows31J

c) JAVA also not recognise "cp932" alias as well see link [2].

d) If we check the Oracle documentation [3], using MS932 should work. Also, CP932 does not fall under Canonical Name for java.nio API as well as Canonical Name for java.io and java.lang API.

e) So "cp932" is not the correct name that should be used,follow the [4] bugzilla link. So in order to avoid this issue try to use MS932.

[1] http://en.wikipedia.org/wiki/Code_page_932

[2] http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/sun/nio/cs/ext/ExtendedCharsets.java#ExtendedCharsets.%3Cinit%3E%28%29

[3] http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html

[4] https://issues.apache.org/bugzilla/show_bug.cgi?id=45852

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments