2362N/A * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @bug 4085160 4139951 5005831 0N/A * @summary Test that required character encodings are supported 0N/A if (a[i] != b[i])
return false;
0N/A /* String(byte[] bs, String enc) */ 0N/A /* String(byte[] bs, Charset charset) */ 0N/A /* String(byte[] bs, int off, int len, Charset charset) */ 0N/A /* InputStreamReader */ 0N/A for (
int i =
0; i < n;) {
0N/A /* String.getBytes(String enc) */ 0N/A /* String.getBytes(Charset charset) */ 0N/A // Calls to String.getBytes(Charset) shouldn't automatically 0N/A // use the cached thread-local encoder. 0N/A // Replace the thread-local encoder with this one. 0N/A // Expect different byte[] between UTF-16LE and UTF-16BE 0N/A // even though encoder was previously cached by last call 0N/A /* OutputStreamWriter */ 0N/A go(
"US-ASCII",
"abc",
new byte[] {
'a',
'b',
'c' });
0N/A go(
"us-ascii",
"abc",
new byte[] {
'a',
'b',
'c' });
0N/A go(
"ISO646-US",
"abc",
new byte[] {
'a',
'b',
'c' });
0N/A go(
"ISO-8859-1",
"ab\u00c7",
new byte[] {
'a',
'b', (
byte)
'\u00c7' });
0N/A new byte[] {
'a',
'b',
0N/A (
byte)(
0xe0 | (
0x0f & (
0x1e09 >>
12))),
0N/A (
byte)(
0x80 | (
0x3f & (
0x1e09 >>
6))),
0N/A (
byte)(
0x80 | (
0x3f &
0x1e09)) });
0N/A go(
"UTF-16BE",
"ab\u1e09",
0N/A new byte[] {
0,
'a',
0,
'b',
0x1e,
0x09 });
0N/A go(
"UTF-16LE",
"ab\u1e09",
0N/A new byte[] {
'a',
0,
'b',
0,
0x09,
0x1e });
0N/A /* UTF-16 accepts both byte orders on input but always uses big-endian 0N/A * on output, so test all three cases 0N/A new byte[] { (
byte)
0xfe, (
byte)
0xff,
0,
'a',
0,
'b',
0x1e,
0x09 });
0N/A new byte[] { (
byte)
0xff, (
byte)
0xfe,
'a',
0,
'b',
0,
0x09,
0x1e },