<i18n dev> Codereview request for 6995537: different behavior in iso-2022-jp encoding between jdk131/140/141 and jdk142/5/6/7
Ulf Zibis
Ulf.Zibis at gmx.de
Fri Feb 10 13:00:22 UTC 2012
I agree with the fix.
In test/java/io/OutputStreamWriter/Flush.java I suggest:
a) As all values are positive, following would be better readable:
byte[] bytes = new byte[] {0x1b, 0x24, 0x42, 0x3a, 0x47, 0x1b, 0x28, 0x42};
... or remember the format rule - which I still don't like - to insert a space after the cast. ;-)
b) Use the promoted /ugly/ Byte.toUnsignedInt(b) method.
c) Use smart for...each loop
d) I guess, you meant one ':' after "Result"
e) Print "Expected/Result: 0x12 0x34 0x56 ..." in _one_ line, with the values vertically alingned.
f) Anyway, for the output you could use:
private static Formatter formatBytes(CharSequence label, byte[] bytes) {
Formatter f = new Formatter(new StringBuilder(label));
// Formatter f = new Formatter(new StringBuilder(label.length() + 5 *
bytes.length).append(label));
for (byte b : bytes)
f.format(" 0x%x", b Byte.toUnsignedInt(b));
return f;
}
...
System.out.println(formatBytes("Expected:", expected));
System.out.println(formatBytes("Result: ", result));
-Ulf
More information about the core-libs-dev
mailing list