2362N/A * Copyright (c) 2008, 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 4486841 7040220 0N/A * @summary Test UTF-8 charset char[]
ca =
new char[
en];
char[]
cc =
new char[
0x10000 -
0xe000 +
0xd800 +
//bmp (
0x110000 -
0x10000) *
2];
//supp for (i =
0; i <
0xd800; i++)
for (i =
0xe000; i <
0x10000; i++)
for (i =
0x10000; i <
0x110000; i++) {
bb[
pos++] = (
byte)(
0xe0 | ((c >>
12)));
bb[
pos++] = (
byte)(
0x80 | ((c >>
06) &
0x3f));
bb[
pos++] = (
byte)(
0x80 | ((c >>
00) &
0x3f));
byte[]
bb =
new byte[(
0x110000 -
0x10000) *
6];
char[]
cc =
new char[(
0x110000 -
0x10000) *
2];
for (
int i =
0x10000; i <
0x110000; i++) {
// new String(bb, csn).getBytes(csn) will not return // the 6 bytes surrogates as in bb, so only test // The first byte is the length of malformed bytes {
1, (
byte)
0xFF, (
byte)
0xFF},
// all ones {
1, (
byte)
0xA0, (
byte)
0x80},
// 101x first byte first nibble {
1, (
byte)
0xC0, (
byte)
0x80},
// invalid first byte {
1, (
byte)
0xC1, (
byte)
0xBF},
// invalid first byte {
1, (
byte)
0xC2, (
byte)
0x00},
// invalid second byte {
1, (
byte)
0xC2, (
byte)
0xC0},
// invalid second byte {
1, (
byte)
0xD0, (
byte)
0x00},
// invalid second byte {
1, (
byte)
0xD0, (
byte)
0xC0},
// invalid second byte {
1, (
byte)
0xDF, (
byte)
0x00},
// invalid second byte {
1, (
byte)
0xDF, (
byte)
0xC0},
// invalid second byte {
1, (
byte)
0xE0, (
byte)
0x80, (
byte)
0x80},
// 111x first byte first nibble {
1, (
byte)
0xE0, (
byte)
0x80, (
byte)
0x80 },
// U+0000 zero-padded {
1, (
byte)
0xE0, (
byte)
0x81, (
byte)
0xBF },
// U+007F zero-padded {
1, (
byte)
0xE0, (
byte)
0x9F, (
byte)
0xBF },
// U+07FF zero-padded {
1, (
byte)
0xE0, (
byte)
0xC0, (
byte)
0xBF },
// invalid second byte {
2, (
byte)
0xE0, (
byte)
0xA0, (
byte)
0x7F },
// invalid third byte {
2, (
byte)
0xE0, (
byte)
0xA0, (
byte)
0xC0 },
// invalid third byte {
1, (
byte)
0xFF, (
byte)
0xFF, (
byte)
0xFF },
// all ones {
1, (
byte)
0xE0, (
byte)
0xC0, (
byte)
0x80 },
// invalid second byte {
1, (
byte)
0xE0, (
byte)
0x80, (
byte)
0xC0 },
// invalid first byte {
1, (
byte)
0xF0, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80 },
// U+0000 zero-padded {
1, (
byte)
0xF0, (
byte)
0x80, (
byte)
0x81, (
byte)
0xBF },
// U+007F zero-padded {
1, (
byte)
0xF0, (
byte)
0x80, (
byte)
0x9F, (
byte)
0xBF },
// U+007F zero-padded {
1, (
byte)
0xF0, (
byte)
0x8F, (
byte)
0xBF, (
byte)
0xBF },
// U+07FF zero-padded {
1, (
byte)
0xFF, (
byte)
0xFF, (
byte)
0xFF, (
byte)
0xFF },
// all ones {
1, (
byte)
0xF0, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80},
// invalid second byte {
1, (
byte)
0xF0, (
byte)
0xC0, (
byte)
0x80, (
byte)
0x80 },
// invalid second byte {
2, (
byte)
0xF0, (
byte)
0x90, (
byte)
0xC0, (
byte)
0x80 },
// invalid third byte {
3, (
byte)
0xF0, (
byte)
0x90, (
byte)
0x80, (
byte)
0xC0 },
// invalid third byte {
1, (
byte)
0xF1, (
byte)
0xC0, (
byte)
0x80, (
byte)
0x80 },
// invalid second byte {
2, (
byte)
0xF1, (
byte)
0x80, (
byte)
0xC0, (
byte)
0x80 },
// invalid third byte {
3, (
byte)
0xF1, (
byte)
0x80, (
byte)
0x80, (
byte)
0xC0 },
// invalid forth byte {
1, (
byte)
0xF4, (
byte)
0x90, (
byte)
0x80, (
byte)
0xC0 },
// out-range 4-byte {
1, (
byte)
0xF4, (
byte)
0xC0, (
byte)
0x80, (
byte)
0xC0 },
// out-range 4-byte {
1, (
byte)
0xF5, (
byte)
0x80, (
byte)
0x80, (
byte)
0xC0 },
// out-range 4-byte {
5, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80},
// invalid first byte {
5, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80 },
// U+0000 zero-padded {
5, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0x81, (
byte)
0xBF },
// U+007F zero-padded {
5, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0x9F, (
byte)
0xBF },
// U+07FF zero-padded {
5, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x8F, (
byte)
0xBF, (
byte)
0xBF },
// U+FFFF zero-padded {
1, (
byte)
0xF8, (
byte)
0xC0, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80},
{
2, (
byte)
0xF8, (
byte)
0x80, (
byte)
0xC0, (
byte)
0x80, (
byte)
0x80 },
{
3, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0xC1, (
byte)
0xBF },
{
4, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0x9F, (
byte)
0xC0 },
{
6, (
byte)
0xFC, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80 },
// U+0000 zero-padded {
6, (
byte)
0xFC, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80, (
byte)
0x81, (
byte)
0xBF },
// U+007F zero-padded {
6, (
byte)
0xFC, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80, (
byte)
0x9F, (
byte)
0xBF },
// U+07FF zero-padded {
6, (
byte)
0xFC, (
byte)
0x80, (
byte)
0x80, (
byte)
0x8F, (
byte)
0xBF, (
byte)
0xBF },
// U+FFFF zero-padded {
1, (
byte)
0xF8, (
byte)
0xC0, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80 },
{
2, (
byte)
0xF8, (
byte)
0x80, (
byte)
0xC0, (
byte)
0x80, (
byte)
0x80, (
byte)
0x80 },
{
3, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0xC1, (
byte)
0xBF, (
byte)
0x80 },
{
4, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0x9F, (
byte)
0xC0, (
byte)
0x80 },
{
5, (
byte)
0xF8, (
byte)
0x80, (
byte)
0x80, (
byte)
0x9F, (
byte)
0x80, (
byte)
0xC0 },
for (
boolean direct:
new boolean[] {
false,
true}) {
//inpos, inLen, outPos, outLen, inPosEP, outposEP, under(0)/over(1) for (
boolean direct:
new boolean[] {
false,
true}) {
//compare("UTF-8", "UTF-8-OLD");