for (int i = 0 ; i < charsetNames.length; i++) {
Charset cs = Charset.forName(charsetNames[i]);
CharsetDecoder decoder = cs.newDecoder();
bb.clear();
cc.clear();
// Fakes a partial 3 byte EUC_JP (JIS-X-0212 range) // encoded character/byte sequence
bb.put((byte)0x8f);
bb.put((byte)0xa2);
bb.flip(); // Now decode with endOfInput method param set to // indicate to decoder that there is more encoded // data to follow in a subsequent invocation
CoderResult result = decoder.decode(bb, cc, false);
// java.nio.charset.CharsetDecoder spec specifies // that the coder ought to return CoderResult.UNDERFLOW // when insufficient bytes have been supplied to complete // the decoding operation
if (result != CoderResult.UNDERFLOW) { thrownew Exception("test failed - UNDERFLOW not returned");
}
// Repeat the test with the lead byte (minus its pursuing // trail byte) for the EUC-JP 2 byte (JIS208) range
decoder.reset();
bb.clear();
cc.clear();
bb.put((byte)0xa1);
bb.flip();
result = decoder.decode(bb, cc, false); if (result != CoderResult.UNDERFLOW) { thrownew Exception("test failed");
}
// finally ensure that a valid JIS208 range EUC-JP // 2 byte value is correctly decoded when it is presented // at the trailing bounds of a ByteBuffer in the case where // charset decoder expects (endOfInput ==false) more //input to follow
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.