/* The fix for 6378911 is to backout the change we made for 4508058, sothisregtestismodifiedaccordinglytoleavethebeginning BOMuntouchedduringdecoding.
*/ publicclass TestUTF8BOM { privatestatic ByteBuffer bf = ByteBuffer.allocateDirect(1000); privatestaticvoid testDecode(String expected, byte[] input) throws Exception
{
String out = new String(input, "utf8"); if (!out.equals(expected)) {
failureReport (out, expected); thrownew Exception("UTF_8 Decoding test failed");
}
//try directBuffer.
bf.clear();
bf.put(input).flip();
out = Charset.forName("UTF-8")
.decode(bf)
.toString(); if (!out.equals(expected)) {
failureReport (out, expected); thrownew Exception("UTF_8 Decoding test failed(directbuffer)");
}
}
System.err.println ("Expected Characters:"); for (int i = 0; i < expected.length() ; i++) {
System.out.println("expected char[" + i + "] : " +
Integer.toHexString((int)expected.charAt(i)) + " obtained char[" + i + "] : " +
Integer.toHexString((int)testStr.charAt(i)));
}
}
publicstaticvoid main (String[] args) throws Exception { // Test 1: with BOM at beginning
testDecode("\ufeff\u0092\u0093", newbyte[] { (byte) 0xef, (byte) 0xbb, (byte) 0xbf,
(byte) 0xc2, (byte) 0x92,
(byte) 0xc2, (byte) 0x93 }); // Test 2: with BOM at middle
testDecode("\u9200\ufeff\u9300", newbyte[] { (byte) 0xe9, (byte) 0x88, (byte) 0x80,
(byte) 0xef, (byte) 0xbb, (byte) 0xbf,
(byte) 0xe9, (byte) 0x8c, (byte) 0x80 });
// Test 3: with BOM at end
testDecode("\u9200\u9300\ufeff", newbyte[] { (byte) 0xe9, (byte) 0x88, (byte) 0x80,
(byte) 0xe9, (byte) 0x8c, (byte) 0x80,
(byte) 0xef, (byte) 0xbb, (byte) 0xbf });
System.err.println ("\nPASSED UTF-8 decode BOM test");
}
}
Messung V0.5 in Prozent
¤ 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.0.8Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
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.