ByteBuffer buf = ByteBuffer.wrap(bytes.getUnsafeBytes(), bytes.begin(), bytes.length());
CharsetDecoder decoder;
try {
decoder = Charset.forName("x-JISAutoDetect").newDecoder();
} catch (UnsupportedCharsetException e) {
throw runtime.newStandardError("charsets.jar is required to use NKF#guess. Please install JRE which supports m17n.");
}
try {
decoder.decode(buf);
} catch (CharacterCodingException e) {
return runtime.newFixnum(UNKNOWN.getValue());