feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
198
jdkSrc/jdk8/sun/nio/cs/AbstractCharsetProvider.java
Normal file
198
jdkSrc/jdk8/sun/nio/cs/AbstractCharsetProvider.java
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.spi.CharsetProvider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import sun.misc.ASCIICaseInsensitiveComparator;
|
||||
|
||||
/**
|
||||
* Abstract base class for charset providers.
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
*/
|
||||
|
||||
public class AbstractCharsetProvider
|
||||
extends CharsetProvider
|
||||
{
|
||||
|
||||
/* Maps canonical names to class names
|
||||
*/
|
||||
private Map<String,String> classMap
|
||||
= new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
/* Maps alias names to canonical names
|
||||
*/
|
||||
private Map<String,String> aliasMap
|
||||
= new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
/* Maps canonical names to alias-name arrays
|
||||
*/
|
||||
private Map<String,String[]> aliasNameMap
|
||||
= new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
/* Maps canonical names to soft references that hold cached instances
|
||||
*/
|
||||
private Map<String,SoftReference<Charset>> cache
|
||||
= new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
private String packagePrefix;
|
||||
|
||||
protected AbstractCharsetProvider() {
|
||||
packagePrefix = "sun.nio.cs";
|
||||
}
|
||||
|
||||
protected AbstractCharsetProvider(String pkgPrefixName) {
|
||||
packagePrefix = pkgPrefixName;
|
||||
}
|
||||
|
||||
/* Add an entry to the given map, but only if no mapping yet exists
|
||||
* for the given name.
|
||||
*/
|
||||
private static <K,V> void put(Map<K,V> m, K name, V value) {
|
||||
if (!m.containsKey(name))
|
||||
m.put(name, value);
|
||||
}
|
||||
|
||||
private static <K,V> void remove(Map<K,V> m, K name) {
|
||||
V x = m.remove(name);
|
||||
assert (x != null);
|
||||
}
|
||||
|
||||
/* Declare support for the given charset
|
||||
*/
|
||||
protected void charset(String name, String className, String[] aliases) {
|
||||
synchronized (this) {
|
||||
put(classMap, name, className);
|
||||
for (int i = 0; i < aliases.length; i++)
|
||||
put(aliasMap, aliases[i], name);
|
||||
put(aliasNameMap, name, aliases);
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteCharset(String name, String[] aliases) {
|
||||
synchronized (this) {
|
||||
remove(classMap, name);
|
||||
for (int i = 0; i < aliases.length; i++)
|
||||
remove(aliasMap, aliases[i]);
|
||||
remove(aliasNameMap, name);
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/* Late initialization hook, needed by some providers
|
||||
*/
|
||||
protected void init() { }
|
||||
|
||||
private String canonicalize(String charsetName) {
|
||||
String acn = aliasMap.get(charsetName);
|
||||
return (acn != null) ? acn : charsetName;
|
||||
}
|
||||
|
||||
private Charset lookup(String csn) {
|
||||
|
||||
// Check cache first
|
||||
SoftReference<Charset> sr = cache.get(csn);
|
||||
if (sr != null) {
|
||||
Charset cs = sr.get();
|
||||
if (cs != null)
|
||||
return cs;
|
||||
}
|
||||
|
||||
// Do we even support this charset?
|
||||
String cln = classMap.get(csn);
|
||||
|
||||
if (cln == null)
|
||||
return null;
|
||||
|
||||
// Instantiate the charset and cache it
|
||||
try {
|
||||
|
||||
Class<?> c = Class.forName(packagePrefix + "." + cln,
|
||||
true,
|
||||
this.getClass().getClassLoader());
|
||||
|
||||
Charset cs = (Charset)c.newInstance();
|
||||
cache.put(csn, new SoftReference<Charset>(cs));
|
||||
return cs;
|
||||
} catch (ClassNotFoundException x) {
|
||||
return null;
|
||||
} catch (IllegalAccessException x) {
|
||||
return null;
|
||||
} catch (InstantiationException x) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final Charset charsetForName(String charsetName) {
|
||||
synchronized (this) {
|
||||
init();
|
||||
return lookup(canonicalize(charsetName));
|
||||
}
|
||||
}
|
||||
|
||||
public final Iterator<Charset> charsets() {
|
||||
|
||||
final ArrayList<String> ks;
|
||||
synchronized (this) {
|
||||
init();
|
||||
ks = new ArrayList<>(classMap.keySet());
|
||||
}
|
||||
|
||||
return new Iterator<Charset>() {
|
||||
Iterator<String> i = ks.iterator();
|
||||
|
||||
public boolean hasNext() {
|
||||
return i.hasNext();
|
||||
}
|
||||
|
||||
public Charset next() {
|
||||
String csn = i.next();
|
||||
synchronized (AbstractCharsetProvider.this) {
|
||||
return lookup(csn);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public final String[] aliases(String charsetName) {
|
||||
synchronized (this) {
|
||||
init();
|
||||
return aliasNameMap.get(charsetName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
35
jdkSrc/jdk8/sun/nio/cs/ArrayDecoder.java
Normal file
35
jdkSrc/jdk8/sun/nio/cs/ArrayDecoder.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
/*
|
||||
* FastPath byte[]->char[] decoder, REPLACE on malformed or
|
||||
* unmappable input.
|
||||
*/
|
||||
|
||||
public interface ArrayDecoder {
|
||||
int decode(byte[] src, int off, int len, char[] dst);
|
||||
}
|
||||
35
jdkSrc/jdk8/sun/nio/cs/ArrayEncoder.java
Normal file
35
jdkSrc/jdk8/sun/nio/cs/ArrayEncoder.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
/*
|
||||
* FastPath char[]->byte[] encoder, REPLACE on malformed input or
|
||||
* unmappable input.
|
||||
*/
|
||||
|
||||
public interface ArrayEncoder {
|
||||
int encode(char[] src, int off, int len, byte[] dst);
|
||||
}
|
||||
604
jdkSrc/jdk8/sun/nio/cs/CESU_8.java
Normal file
604
jdkSrc/jdk8/sun/nio/cs/CESU_8.java
Normal file
@@ -0,0 +1,604 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
/* Legal CESU-8 Byte Sequences
|
||||
*
|
||||
* # Code Points Bits Bit/Byte pattern
|
||||
* 1 7 0xxxxxxx
|
||||
* U+0000..U+007F 00..7F
|
||||
*
|
||||
* 2 11 110xxxxx 10xxxxxx
|
||||
* U+0080..U+07FF C2..DF 80..BF
|
||||
*
|
||||
* 3 16 1110xxxx 10xxxxxx 10xxxxxx
|
||||
* U+0800..U+0FFF E0 A0..BF 80..BF
|
||||
* U+1000..U+FFFF E1..EF 80..BF 80..BF
|
||||
*
|
||||
*/
|
||||
|
||||
class CESU_8 extends Unicode
|
||||
{
|
||||
public CESU_8() {
|
||||
super("CESU-8", StandardCharsets.aliases_CESU_8);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "CESU8";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static final void updatePositions(Buffer src, int sp,
|
||||
Buffer dst, int dp) {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
|
||||
private static class Decoder extends CharsetDecoder
|
||||
implements ArrayDecoder {
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
private static boolean isNotContinuation(int b) {
|
||||
return (b & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// [E0] [A0..BF] [80..BF]
|
||||
// [E1..EF] [80..BF] [80..BF]
|
||||
private static boolean isMalformed3(int b1, int b2, int b3) {
|
||||
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
(b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is only one byte left in src buffer
|
||||
private static boolean isMalformed3_2(int b1, int b2) {
|
||||
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
|
||||
// [F0] [90..BF] [80..BF] [80..BF]
|
||||
// [F1..F3] [80..BF] [80..BF] [80..BF]
|
||||
// [F4] [80..8F] [80..BF] [80..BF]
|
||||
// only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
|
||||
// will be checked by Character.isSupplementaryCodePoint(uc)
|
||||
private static boolean isMalformed4(int b2, int b3, int b4) {
|
||||
return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
|
||||
(b4 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is less than 4 bytes left in src buffer
|
||||
private static boolean isMalformed4_2(int b1, int b2) {
|
||||
return (b1 == 0xf0 && b2 == 0x90) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
private static boolean isMalformed4_3(int b3) {
|
||||
return (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
private static CoderResult malformedN(ByteBuffer src, int nb) {
|
||||
switch (nb) {
|
||||
case 1:
|
||||
case 2: // always 1
|
||||
return CoderResult.malformedForLength(1);
|
||||
case 3:
|
||||
int b1 = src.get();
|
||||
int b2 = src.get(); // no need to lookup b3
|
||||
return CoderResult.malformedForLength(
|
||||
((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
isNotContinuation(b2)) ? 1 : 2);
|
||||
case 4: // we don't care the speed here
|
||||
b1 = src.get() & 0xff;
|
||||
b2 = src.get() & 0xff;
|
||||
if (b1 > 0xf4 ||
|
||||
(b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
|
||||
(b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
|
||||
isNotContinuation(b2))
|
||||
return CoderResult.malformedForLength(1);
|
||||
if (isNotContinuation(src.get()))
|
||||
return CoderResult.malformedForLength(2);
|
||||
return CoderResult.malformedForLength(3);
|
||||
default:
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static CoderResult malformed(ByteBuffer src, int sp,
|
||||
CharBuffer dst, int dp,
|
||||
int nb)
|
||||
{
|
||||
src.position(sp - src.arrayOffset());
|
||||
CoderResult cr = malformedN(src, nb);
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return cr;
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult malformed(ByteBuffer src,
|
||||
int mark, int nb)
|
||||
{
|
||||
src.position(mark);
|
||||
CoderResult cr = malformedN(src, nb);
|
||||
src.position(mark);
|
||||
return cr;
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int sp,
|
||||
CharBuffer dst,
|
||||
int dp,
|
||||
int malformedNB)
|
||||
{
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int mark,
|
||||
int malformedNB)
|
||||
{
|
||||
src.position(mark);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult xflow(Buffer src, int sp, int sl,
|
||||
Buffer dst, int dp, int nb) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return (nb == 0 || sl - sp < nb)
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static CoderResult xflow(Buffer src, int mark, int nb) {
|
||||
src.position(mark);
|
||||
return (nb == 0 || src.remaining() < nb)
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
// This method is optimized for ASCII input.
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
int dlASCII = dp + Math.min(sl - sp, dl - dp);
|
||||
|
||||
// ASCII only loop
|
||||
while (dp < dlASCII && sa[sp] >= 0)
|
||||
da[dp++] = (char) sa[sp++];
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp];
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
if (dp >= dl)
|
||||
return xflow(src, sp, sl, dst, dp, 1);
|
||||
da[dp++] = (char) b1;
|
||||
sp++;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (sl - sp < 2 || dp >= dl)
|
||||
return xflow(src, sp, sl, dst, dp, 2);
|
||||
int b2 = sa[sp + 1];
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
da[dp++] = (char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0)));
|
||||
sp += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = sl - sp;
|
||||
if (srcRemaining < 3 || dp >= dl) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, sa[sp + 1]))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
return xflow(src, sp, sl, dst, dp, 3);
|
||||
}
|
||||
int b2 = sa[sp + 1];
|
||||
int b3 = sa[sp + 2];
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, sp, dst, dp, 3);
|
||||
da[dp++] = (char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
sp += 3;
|
||||
} else {
|
||||
return malformed(src, sp, dst, dp, 1);
|
||||
}
|
||||
}
|
||||
return xflow(src, sp, sl, dst, dp, 0);
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
int limit = src.limit();
|
||||
while (mark < limit) {
|
||||
int b1 = src.get();
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
if (dst.remaining() < 1)
|
||||
return xflow(src, mark, 1); // overflow
|
||||
dst.put((char) b1);
|
||||
mark++;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (limit - mark < 2|| dst.remaining() < 1)
|
||||
return xflow(src, mark, 2);
|
||||
int b2 = src.get();
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, mark, 1);
|
||||
dst.put((char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
mark += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = limit - mark;
|
||||
if (srcRemaining < 3 || dst.remaining() < 1) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, src.get()))
|
||||
return malformedForLength(src, mark, 1);
|
||||
return xflow(src, mark, 3);
|
||||
}
|
||||
int b2 = src.get();
|
||||
int b3 = src.get();
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, mark, 3);
|
||||
dst.put((char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0)))));
|
||||
mark += 3;
|
||||
} else {
|
||||
return malformed(src, mark, 1);
|
||||
}
|
||||
}
|
||||
return xflow(src, mark, 0);
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private static ByteBuffer getByteBuffer(ByteBuffer bb, byte[] ba, int sp)
|
||||
{
|
||||
if (bb == null)
|
||||
bb = ByteBuffer.wrap(ba);
|
||||
bb.position(sp);
|
||||
return bb;
|
||||
}
|
||||
|
||||
// returns -1 if there is/are malformed byte(s) and the
|
||||
// "action" for malformed input is not REPLACE.
|
||||
public int decode(byte[] sa, int sp, int len, char[] da) {
|
||||
final int sl = sp + len;
|
||||
int dp = 0;
|
||||
int dlASCII = Math.min(len, da.length);
|
||||
ByteBuffer bb = null; // only necessary if malformed
|
||||
|
||||
// ASCII only optimized loop
|
||||
while (dp < dlASCII && sa[sp] >= 0)
|
||||
da[dp++] = (char) sa[sp++];
|
||||
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp++];
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
da[dp++] = (char) b1;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (sp < sl) {
|
||||
int b2 = sa[sp++];
|
||||
if (isNotContinuation(b2)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp--; // malformedN(bb, 2) always returns 1
|
||||
} else {
|
||||
da[dp++] = (char) (((b1 << 6) ^ b2)^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0)));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
if (sp + 1 < sl) {
|
||||
int b2 = sa[sp++];
|
||||
int b3 = sa[sp++];
|
||||
if (isMalformed3(b1, b2, b3)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp -=3;
|
||||
bb = getByteBuffer(bb, sa, sp);
|
||||
sp += malformedN(bb, 3).length();
|
||||
} else {
|
||||
da[dp++] = (char)((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
if (sp < sl && isMalformed3_2(b1, sa[sp])) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
|
||||
}
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder {
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, 1.1f, 3.0f);
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return !Character.isSurrogate(c);
|
||||
}
|
||||
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return ((repl.length == 1 && repl[0] >= 0) ||
|
||||
super.isLegalReplacement(repl));
|
||||
}
|
||||
|
||||
private static CoderResult overflow(CharBuffer src, int sp,
|
||||
ByteBuffer dst, int dp) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static CoderResult overflow(CharBuffer src, int mark) {
|
||||
src.position(mark);
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static void to3Bytes(byte[] da, int dp, char c) {
|
||||
da[dp] = (byte)(0xe0 | ((c >> 12)));
|
||||
da[dp + 1] = (byte)(0x80 | ((c >> 6) & 0x3f));
|
||||
da[dp + 2] = (byte)(0x80 | (c & 0x3f));
|
||||
}
|
||||
|
||||
private static void to3Bytes(ByteBuffer dst, char c) {
|
||||
dst.put((byte)(0xe0 | ((c >> 12))));
|
||||
dst.put((byte)(0x80 | ((c >> 6) & 0x3f)));
|
||||
dst.put((byte)(0x80 | (c & 0x3f)));
|
||||
}
|
||||
|
||||
private Surrogate.Parser sgp;
|
||||
private char[] c2;
|
||||
private CoderResult encodeArrayLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
int dlASCII = dp + Math.min(sl - sp, dl - dp);
|
||||
|
||||
// ASCII only loop
|
||||
while (dp < dlASCII && sa[sp] < '\u0080')
|
||||
da[dp++] = (byte) sa[sp++];
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
if (dp >= dl)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)c;
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
if (dl - dp < 2)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)(0xc0 | (c >> 6));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
// Have a surrogate pair
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, sa, sp, sl);
|
||||
if (uc < 0) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return sgp.error();
|
||||
}
|
||||
if (dl - dp < 6)
|
||||
return overflow(src, sp, dst, dp);
|
||||
to3Bytes(da, dp, Character.highSurrogate(uc));
|
||||
dp += 3;
|
||||
to3Bytes(da, dp, Character.lowSurrogate(uc));
|
||||
dp += 3;
|
||||
sp++; // 2 chars
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
if (dl - dp < 3)
|
||||
return overflow(src, sp, dst, dp);
|
||||
to3Bytes(da, dp, c);
|
||||
dp += 3;
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
if (!dst.hasRemaining())
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)c);
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
if (dst.remaining() < 2)
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)(0xc0 | (c >> 6)));
|
||||
dst.put((byte)(0x80 | (c & 0x3f)));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
// Have a surrogate pair
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, src);
|
||||
if (uc < 0) {
|
||||
src.position(mark);
|
||||
return sgp.error();
|
||||
}
|
||||
if (dst.remaining() < 6)
|
||||
return overflow(src, mark);
|
||||
to3Bytes(dst, Character.highSurrogate(uc));
|
||||
to3Bytes(dst, Character.lowSurrogate(uc));
|
||||
mark++; // 2 chars
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
if (dst.remaining() < 3)
|
||||
return overflow(src, mark);
|
||||
to3Bytes(dst, c);
|
||||
}
|
||||
mark++;
|
||||
}
|
||||
src.position(mark);
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
protected final CoderResult encodeLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
// returns -1 if there is malformed char(s) and the
|
||||
// "action" for malformed input is not REPLACE.
|
||||
public int encode(char[] sa, int sp, int len, byte[] da) {
|
||||
int sl = sp + len;
|
||||
int dp = 0;
|
||||
int dlASCII = dp + Math.min(len, da.length);
|
||||
|
||||
// ASCII only optimized loop
|
||||
while (dp < dlASCII && sa[sp] < '\u0080')
|
||||
da[dp++] = (byte) sa[sp++];
|
||||
|
||||
while (sp < sl) {
|
||||
char c = sa[sp++];
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
da[dp++] = (byte)c;
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
da[dp++] = (byte)(0xc0 | (c >> 6));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, sa, sp - 1, sl);
|
||||
if (uc < 0) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement()[0];
|
||||
} else {
|
||||
to3Bytes(da, dp, Character.highSurrogate(uc));
|
||||
dp += 3;
|
||||
to3Bytes(da, dp, Character.lowSurrogate(uc));
|
||||
dp += 3;
|
||||
sp++; // 2 chars
|
||||
}
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
to3Bytes(da, dp, c);
|
||||
dp += 3;
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
}
|
||||
353
jdkSrc/jdk8/sun/nio/cs/CharsetMapping.java
Normal file
353
jdkSrc/jdk8/sun/nio/cs/CharsetMapping.java
Normal file
@@ -0,0 +1,353 @@
|
||||
/*
|
||||
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.*;
|
||||
import java.security.*;
|
||||
|
||||
public class CharsetMapping {
|
||||
public final static char UNMAPPABLE_DECODING = '\uFFFD';
|
||||
public final static int UNMAPPABLE_ENCODING = 0xFFFD;
|
||||
|
||||
char[] b2cSB; //singlebyte b->c
|
||||
char[] b2cDB1; //dobulebyte b->c /db1
|
||||
char[] b2cDB2; //dobulebyte b->c /db2
|
||||
|
||||
int b2Min, b2Max; //min/max(start/end) value of 2nd byte
|
||||
int b1MinDB1, b1MaxDB1; //min/Max(start/end) value of 1st byte/db1
|
||||
int b1MinDB2, b1MaxDB2; //min/Max(start/end) value of 1st byte/db2
|
||||
int dbSegSize;
|
||||
|
||||
char[] c2b;
|
||||
char[] c2bIndex;
|
||||
|
||||
// Supplementary
|
||||
char[] b2cSupp;
|
||||
char[] c2bSupp;
|
||||
|
||||
// Composite
|
||||
Entry[] b2cComp;
|
||||
Entry[] c2bComp;
|
||||
|
||||
public char decodeSingle(int b) {
|
||||
return b2cSB[b];
|
||||
}
|
||||
|
||||
public char decodeDouble(int b1, int b2) {
|
||||
if (b2 >= b2Min && b2 < b2Max) {
|
||||
b2 -= b2Min;
|
||||
if (b1 >= b1MinDB1 && b1 <= b1MaxDB1) {
|
||||
b1 -= b1MinDB1;
|
||||
return b2cDB1[b1 * dbSegSize + b2];
|
||||
}
|
||||
if (b1 >= b1MinDB2 && b1 <= b1MaxDB2) {
|
||||
b1 -= b1MinDB2;
|
||||
return b2cDB2[b1 * dbSegSize + b2];
|
||||
}
|
||||
}
|
||||
return UNMAPPABLE_DECODING;
|
||||
}
|
||||
|
||||
// for jis0213 all supplementary characters are in 0x2xxxx range,
|
||||
// so only the xxxx part is now stored, should actually store the
|
||||
// codepoint value instead.
|
||||
public char[] decodeSurrogate(int db, char[] cc) {
|
||||
int end = b2cSupp.length / 2;
|
||||
int i = Arrays.binarySearch(b2cSupp, 0, end, (char)db);
|
||||
if (i >= 0) {
|
||||
Character.toChars(b2cSupp[end + i] + 0x20000, cc, 0);
|
||||
return cc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public char[] decodeComposite(Entry comp, char[] cc) {
|
||||
int i = findBytes(b2cComp, comp);
|
||||
if (i >= 0) {
|
||||
cc[0] = (char)b2cComp[i].cp;
|
||||
cc[1] = (char)b2cComp[i].cp2;
|
||||
return cc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int encodeChar(char ch) {
|
||||
int index = c2bIndex[ch >> 8];
|
||||
if (index == 0xffff)
|
||||
return UNMAPPABLE_ENCODING;
|
||||
return c2b[index + (ch & 0xff)];
|
||||
}
|
||||
|
||||
public int encodeSurrogate(char hi, char lo) {
|
||||
int cp = Character.toCodePoint(hi, lo);
|
||||
if (cp < 0x20000 || cp >= 0x30000)
|
||||
return UNMAPPABLE_ENCODING;
|
||||
int end = c2bSupp.length / 2;
|
||||
int i = Arrays.binarySearch(c2bSupp, 0, end, (char)cp);
|
||||
if (i >= 0)
|
||||
return c2bSupp[end + i];
|
||||
return UNMAPPABLE_ENCODING;
|
||||
}
|
||||
|
||||
public boolean isCompositeBase(Entry comp) {
|
||||
if (comp.cp <= 0x31f7 && comp.cp >= 0xe6) {
|
||||
return (findCP(c2bComp, comp) >= 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int encodeComposite(Entry comp) {
|
||||
int i = findComp(c2bComp, comp);
|
||||
if (i >= 0)
|
||||
return c2bComp[i].bs;
|
||||
return UNMAPPABLE_ENCODING;
|
||||
}
|
||||
|
||||
// init the CharsetMapping object from the .dat binary file
|
||||
public static CharsetMapping get(final InputStream is) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<CharsetMapping>() {
|
||||
public CharsetMapping run() {
|
||||
return new CharsetMapping().load(is);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
public int bs; //byte sequence reps
|
||||
public int cp; //Unicode codepoint
|
||||
public int cp2; //CC of composite
|
||||
}
|
||||
|
||||
static Comparator<Entry> comparatorBytes =
|
||||
new Comparator<Entry>() {
|
||||
public int compare(Entry m1, Entry m2) {
|
||||
return m1.bs - m2.bs;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
}
|
||||
};
|
||||
|
||||
static Comparator<Entry> comparatorCP =
|
||||
new Comparator<Entry>() {
|
||||
public int compare(Entry m1, Entry m2) {
|
||||
return m1.cp - m2.cp;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
}
|
||||
};
|
||||
|
||||
static Comparator<Entry> comparatorComp =
|
||||
new Comparator<Entry>() {
|
||||
public int compare(Entry m1, Entry m2) {
|
||||
int v = m1.cp - m2.cp;
|
||||
if (v == 0)
|
||||
v = m1.cp2 - m2.cp2;
|
||||
return v;
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
}
|
||||
};
|
||||
|
||||
static int findBytes(Entry[] a, Entry k) {
|
||||
return Arrays.binarySearch(a, 0, a.length, k, comparatorBytes);
|
||||
}
|
||||
|
||||
static int findCP(Entry[] a, Entry k) {
|
||||
return Arrays.binarySearch(a, 0, a.length, k, comparatorCP);
|
||||
}
|
||||
|
||||
static int findComp(Entry[] a, Entry k) {
|
||||
return Arrays.binarySearch(a, 0, a.length, k, comparatorComp);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
// tags of different charset mapping tables
|
||||
private final static int MAP_SINGLEBYTE = 0x1; // 0..256 : c
|
||||
private final static int MAP_DOUBLEBYTE1 = 0x2; // min..max: c
|
||||
private final static int MAP_DOUBLEBYTE2 = 0x3; // min..max: c [DB2]
|
||||
private final static int MAP_SUPPLEMENT = 0x5; // db,c
|
||||
private final static int MAP_SUPPLEMENT_C2B = 0x6; // c,db
|
||||
private final static int MAP_COMPOSITE = 0x7; // db,base,cc
|
||||
private final static int MAP_INDEXC2B = 0x8; // index table of c->bb
|
||||
|
||||
private static final boolean readNBytes(InputStream in, byte[] bb, int N)
|
||||
throws IOException
|
||||
{
|
||||
int off = 0;
|
||||
while (N > 0) {
|
||||
int n = in.read(bb, off, N);
|
||||
if (n == -1)
|
||||
return false;
|
||||
N = N - n;
|
||||
off += n;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int off = 0;
|
||||
byte[] bb;
|
||||
private char[] readCharArray() {
|
||||
// first 2 bytes are the number of "chars" stored in this table
|
||||
int size = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
char [] cc = new char[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
cc[i] = (char)(((bb[off++]&0xff)<<8) | (bb[off++]&0xff));
|
||||
}
|
||||
return cc;
|
||||
}
|
||||
|
||||
void readSINGLEBYTE() {
|
||||
char[] map = readCharArray();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
char c = map[i];
|
||||
if (c != UNMAPPABLE_DECODING) {
|
||||
c2b[c2bIndex[c >> 8] + (c&0xff)] = (char)i;
|
||||
}
|
||||
}
|
||||
b2cSB = map;
|
||||
}
|
||||
|
||||
void readINDEXC2B() {
|
||||
char[] map = readCharArray();
|
||||
for (int i = map.length - 1; i >= 0; i--) {
|
||||
if (c2b == null && map[i] != -1) {
|
||||
c2b = new char[map[i] + 256];
|
||||
Arrays.fill(c2b, (char)UNMAPPABLE_ENCODING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
c2bIndex = map;
|
||||
}
|
||||
|
||||
char[] readDB(int b1Min, int b2Min, int segSize) {
|
||||
char[] map = readCharArray();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
char c = map[i];
|
||||
if (c != UNMAPPABLE_DECODING) {
|
||||
int b1 = i / segSize;
|
||||
int b2 = i % segSize;
|
||||
int b = (b1 + b1Min)* 256 + (b2 + b2Min);
|
||||
//System.out.printf(" DB %x\t%x%n", b, c & 0xffff);
|
||||
c2b[c2bIndex[c >> 8] + (c&0xff)] = (char)(b);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
void readDOUBLEBYTE1() {
|
||||
b1MinDB1 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
b1MaxDB1 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
b2Min = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
b2Max = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
dbSegSize = b2Max - b2Min + 1;
|
||||
b2cDB1 = readDB(b1MinDB1, b2Min, dbSegSize);
|
||||
}
|
||||
|
||||
void readDOUBLEBYTE2() {
|
||||
b1MinDB2 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
b1MaxDB2 = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
b2Min = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
b2Max = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
dbSegSize = b2Max - b2Min + 1;
|
||||
b2cDB2 = readDB(b1MinDB2, b2Min, dbSegSize);
|
||||
}
|
||||
|
||||
void readCOMPOSITE() {
|
||||
char[] map = readCharArray();
|
||||
int mLen = map.length/3;
|
||||
b2cComp = new Entry[mLen];
|
||||
c2bComp = new Entry[mLen];
|
||||
for (int i = 0, j= 0; i < mLen; i++) {
|
||||
Entry m = new Entry();
|
||||
m.bs = map[j++];
|
||||
m.cp = map[j++];
|
||||
m.cp2 = map[j++];
|
||||
b2cComp[i] = m;
|
||||
c2bComp[i] = m;
|
||||
}
|
||||
Arrays.sort(c2bComp, 0, c2bComp.length, comparatorComp);
|
||||
}
|
||||
|
||||
CharsetMapping load(InputStream in) {
|
||||
try {
|
||||
// The first 4 bytes are the size of the total data followed in
|
||||
// this .dat file.
|
||||
int len = ((in.read()&0xff) << 24) | ((in.read()&0xff) << 16) |
|
||||
((in.read()&0xff) << 8) | (in.read()&0xff);
|
||||
bb = new byte[len];
|
||||
off = 0;
|
||||
//System.out.printf("In : Total=%d%n", len);
|
||||
// Read in all bytes
|
||||
if (!readNBytes(in, bb, len))
|
||||
throw new RuntimeException("Corrupted data file");
|
||||
in.close();
|
||||
|
||||
while (off < len) {
|
||||
int type = ((bb[off++]&0xff)<<8) | (bb[off++]&0xff);
|
||||
switch(type) {
|
||||
case MAP_INDEXC2B:
|
||||
readINDEXC2B();
|
||||
break;
|
||||
case MAP_SINGLEBYTE:
|
||||
readSINGLEBYTE();
|
||||
break;
|
||||
case MAP_DOUBLEBYTE1:
|
||||
readDOUBLEBYTE1();
|
||||
break;
|
||||
case MAP_DOUBLEBYTE2:
|
||||
readDOUBLEBYTE2();
|
||||
break;
|
||||
case MAP_SUPPLEMENT:
|
||||
b2cSupp = readCharArray();
|
||||
break;
|
||||
case MAP_SUPPLEMENT_C2B:
|
||||
c2bSupp = readCharArray();
|
||||
break;
|
||||
case MAP_COMPOSITE:
|
||||
readCOMPOSITE();
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Corrupted data file");
|
||||
}
|
||||
}
|
||||
bb = null;
|
||||
return this;
|
||||
} catch (IOException x) {
|
||||
x.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
160
jdkSrc/jdk8/sun/nio/cs/FastCharsetProvider.java
Normal file
160
jdkSrc/jdk8/sun/nio/cs/FastCharsetProvider.java
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.spi.CharsetProvider;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for fast charset providers.
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
*/
|
||||
|
||||
public class FastCharsetProvider
|
||||
extends CharsetProvider
|
||||
{
|
||||
|
||||
// Maps canonical names to class names
|
||||
private Map<String,String> classMap;
|
||||
|
||||
// Maps alias names to canonical names
|
||||
private Map<String,String> aliasMap;
|
||||
|
||||
// Maps canonical names to cached instances
|
||||
private Map<String,Charset> cache;
|
||||
|
||||
private String packagePrefix;
|
||||
|
||||
protected FastCharsetProvider(String pp,
|
||||
Map<String,String> am,
|
||||
Map<String,String> cm,
|
||||
Map<String,Charset> c)
|
||||
{
|
||||
packagePrefix = pp;
|
||||
aliasMap = am;
|
||||
classMap = cm;
|
||||
cache = c;
|
||||
}
|
||||
|
||||
private String canonicalize(String csn) {
|
||||
String acn = aliasMap.get(csn);
|
||||
return (acn != null) ? acn : csn;
|
||||
}
|
||||
|
||||
// Private ASCII-only version, optimized for interpretation during startup
|
||||
//
|
||||
private static String toLower(String s) {
|
||||
int n = s.length();
|
||||
boolean allLower = true;
|
||||
for (int i = 0; i < n; i++) {
|
||||
int c = s.charAt(i);
|
||||
if (((c - 'A') | ('Z' - c)) >= 0) {
|
||||
allLower = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allLower)
|
||||
return s;
|
||||
char[] ca = new char[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
int c = s.charAt(i);
|
||||
if (((c - 'A') | ('Z' - c)) >= 0)
|
||||
ca[i] = (char)(c + 0x20);
|
||||
else
|
||||
ca[i] = (char)c;
|
||||
}
|
||||
return new String(ca);
|
||||
}
|
||||
|
||||
private Charset lookup(String charsetName) {
|
||||
|
||||
String csn = canonicalize(toLower(charsetName));
|
||||
|
||||
// Check cache first
|
||||
Charset cs = cache.get(csn);
|
||||
if (cs != null)
|
||||
return cs;
|
||||
|
||||
// Do we even support this charset?
|
||||
String cln = classMap.get(csn);
|
||||
if (cln == null)
|
||||
return null;
|
||||
|
||||
if (cln.equals("US_ASCII")) {
|
||||
cs = new US_ASCII();
|
||||
cache.put(csn, cs);
|
||||
return cs;
|
||||
}
|
||||
|
||||
// Instantiate the charset and cache it
|
||||
try {
|
||||
Class<?> c = Class.forName(packagePrefix + "." + cln,
|
||||
true,
|
||||
this.getClass().getClassLoader());
|
||||
cs = (Charset)c.newInstance();
|
||||
cache.put(csn, cs);
|
||||
return cs;
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
InstantiationException x) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final Charset charsetForName(String charsetName) {
|
||||
synchronized (this) {
|
||||
return lookup(canonicalize(charsetName));
|
||||
}
|
||||
}
|
||||
|
||||
public final Iterator<Charset> charsets() {
|
||||
|
||||
return new Iterator<Charset>() {
|
||||
|
||||
Iterator<String> i = classMap.keySet().iterator();
|
||||
|
||||
public boolean hasNext() {
|
||||
return i.hasNext();
|
||||
}
|
||||
|
||||
public Charset next() {
|
||||
String csn = i.next();
|
||||
return lookup(csn);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
33
jdkSrc/jdk8/sun/nio/cs/HistoricallyNamedCharset.java
Normal file
33
jdkSrc/jdk8/sun/nio/cs/HistoricallyNamedCharset.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
|
||||
public interface HistoricallyNamedCharset {
|
||||
|
||||
public String historicalName();
|
||||
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM437.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM437.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM437 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM437() {
|
||||
super("IBM437", StandardCharsets.aliases_IBM437);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp437";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM437);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7" + // 0x80 - 0x87
|
||||
"\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5" + // 0x88 - 0x8f
|
||||
"\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9" + // 0x90 - 0x97
|
||||
"\u00FF\u00D6\u00DC\u00A2\u00A3\u00A5\u20A7\u0192" + // 0x98 - 0x9f
|
||||
"\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA" + // 0xa0 - 0xa7
|
||||
"\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556" + // 0xb0 - 0xb7
|
||||
"\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567" + // 0xc8 - 0xcf
|
||||
"\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B" + // 0xd0 - 0xd7
|
||||
"\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580" + // 0xd8 - 0xdf
|
||||
"\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4" + // 0xe0 - 0xe7
|
||||
"\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229" + // 0xe8 - 0xef
|
||||
"\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248" + // 0xf0 - 0xf7
|
||||
"\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x700];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM737.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM737.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM737 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM737() {
|
||||
super("x-IBM737", StandardCharsets.aliases_IBM737);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp737";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM737);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398" + // 0x80 - 0x87
|
||||
"\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0" + // 0x88 - 0x8f
|
||||
"\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9" + // 0x90 - 0x97
|
||||
"\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8" + // 0x98 - 0x9f
|
||||
"\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0" + // 0xa0 - 0xa7
|
||||
"\u03C1\u03C3\u03C2\u03C4\u03C5\u03C6\u03C7\u03C8" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556" + // 0xb0 - 0xb7
|
||||
"\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567" + // 0xc8 - 0xcf
|
||||
"\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B" + // 0xd0 - 0xd7
|
||||
"\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580" + // 0xd8 - 0xdf
|
||||
"\u03C9\u03AC\u03AD\u03AE\u03CA\u03AF\u03CC\u03CD" + // 0xe0 - 0xe7
|
||||
"\u03CB\u03CE\u0386\u0388\u0389\u038A\u038C\u038E" + // 0xe8 - 0xef
|
||||
"\u038F\u00B1\u2265\u2264\u03AA\u03AB\u00F7\u2248" + // 0xf0 - 0xf7
|
||||
"\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM775.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM775.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM775 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM775() {
|
||||
super("IBM775", StandardCharsets.aliases_IBM775);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp775";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM775);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0106\u00FC\u00E9\u0101\u00E4\u0123\u00E5\u0107" + // 0x80 - 0x87
|
||||
"\u0142\u0113\u0156\u0157\u012B\u0179\u00C4\u00C5" + // 0x88 - 0x8f
|
||||
"\u00C9\u00E6\u00C6\u014D\u00F6\u0122\u00A2\u015A" + // 0x90 - 0x97
|
||||
"\u015B\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u00A4" + // 0x98 - 0x9f
|
||||
"\u0100\u012A\u00F3\u017B\u017C\u017A\u201D\u00A6" + // 0xa0 - 0xa7
|
||||
"\u00A9\u00AE\u00AC\u00BD\u00BC\u0141\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u0104\u010C\u0118" + // 0xb0 - 0xb7
|
||||
"\u0116\u2563\u2551\u2557\u255D\u012E\u0160\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u0172\u016A" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u017D" + // 0xc8 - 0xcf
|
||||
"\u0105\u010D\u0119\u0117\u012F\u0161\u0173\u016B" + // 0xd0 - 0xd7
|
||||
"\u017E\u2518\u250C\u2588\u2584\u258C\u2590\u2580" + // 0xd8 - 0xdf
|
||||
"\u00D3\u00DF\u014C\u0143\u00F5\u00D5\u00B5\u0144" + // 0xe0 - 0xe7
|
||||
"\u0136\u0137\u013B\u013C\u0146\u0112\u0145\u2019" + // 0xe8 - 0xef
|
||||
"\u00AD\u00B1\u201C\u00BE\u00B6\u00A7\u00F7\u201E" + // 0xf0 - 0xf7
|
||||
"\u00B0\u2219\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM850.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM850.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM850 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM850() {
|
||||
super("IBM850", StandardCharsets.aliases_IBM850);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp850";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM850);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7" + // 0x80 - 0x87
|
||||
"\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5" + // 0x88 - 0x8f
|
||||
"\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9" + // 0x90 - 0x97
|
||||
"\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192" + // 0x98 - 0x9f
|
||||
"\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA" + // 0xa0 - 0xa7
|
||||
"\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0" + // 0xb0 - 0xb7
|
||||
"\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4" + // 0xc8 - 0xcf
|
||||
"\u00F0\u00D0\u00CA\u00CB\u00C8\u0131\u00CD\u00CE" + // 0xd0 - 0xd7
|
||||
"\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580" + // 0xd8 - 0xdf
|
||||
"\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\u00FE" + // 0xe0 - 0xe7
|
||||
"\u00DE\u00DA\u00DB\u00D9\u00FD\u00DD\u00AF\u00B4" + // 0xe8 - 0xef
|
||||
"\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8" + // 0xf0 - 0xf7
|
||||
"\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM852.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM852.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM852 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM852() {
|
||||
super("IBM852", StandardCharsets.aliases_IBM852);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp852";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM852);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00C7\u00FC\u00E9\u00E2\u00E4\u016F\u0107\u00E7" + // 0x80 - 0x87
|
||||
"\u0142\u00EB\u0150\u0151\u00EE\u0179\u00C4\u0106" + // 0x88 - 0x8f
|
||||
"\u00C9\u0139\u013A\u00F4\u00F6\u013D\u013E\u015A" + // 0x90 - 0x97
|
||||
"\u015B\u00D6\u00DC\u0164\u0165\u0141\u00D7\u010D" + // 0x98 - 0x9f
|
||||
"\u00E1\u00ED\u00F3\u00FA\u0104\u0105\u017D\u017E" + // 0xa0 - 0xa7
|
||||
"\u0118\u0119\u00AC\u017A\u010C\u015F\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u011A" + // 0xb0 - 0xb7
|
||||
"\u015E\u2563\u2551\u2557\u255D\u017B\u017C\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u0102\u0103" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4" + // 0xc8 - 0xcf
|
||||
"\u0111\u0110\u010E\u00CB\u010F\u0147\u00CD\u00CE" + // 0xd0 - 0xd7
|
||||
"\u011B\u2518\u250C\u2588\u2584\u0162\u016E\u2580" + // 0xd8 - 0xdf
|
||||
"\u00D3\u00DF\u00D4\u0143\u0144\u0148\u0160\u0161" + // 0xe0 - 0xe7
|
||||
"\u0154\u00DA\u0155\u0170\u00FD\u00DD\u0163\u00B4" + // 0xe8 - 0xef
|
||||
"\u00AD\u02DD\u02DB\u02C7\u02D8\u00A7\u00F7\u00B8" + // 0xf0 - 0xf7
|
||||
"\u00B0\u00A8\u02D9\u0171\u0158\u0159\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM855.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM855.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM855 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM855() {
|
||||
super("IBM855", StandardCharsets.aliases_IBM855);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp855";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM855);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0452\u0402\u0453\u0403\u0451\u0401\u0454\u0404" + // 0x80 - 0x87
|
||||
"\u0455\u0405\u0456\u0406\u0457\u0407\u0458\u0408" + // 0x88 - 0x8f
|
||||
"\u0459\u0409\u045A\u040A\u045B\u040B\u045C\u040C" + // 0x90 - 0x97
|
||||
"\u045E\u040E\u045F\u040F\u044E\u042E\u044A\u042A" + // 0x98 - 0x9f
|
||||
"\u0430\u0410\u0431\u0411\u0446\u0426\u0434\u0414" + // 0xa0 - 0xa7
|
||||
"\u0435\u0415\u0444\u0424\u0433\u0413\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u0445\u0425\u0438" + // 0xb0 - 0xb7
|
||||
"\u0418\u2563\u2551\u2557\u255D\u0439\u0419\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u043A\u041A" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4" + // 0xc8 - 0xcf
|
||||
"\u043B\u041B\u043C\u041C\u043D\u041D\u043E\u041E" + // 0xd0 - 0xd7
|
||||
"\u043F\u2518\u250C\u2588\u2584\u041F\u044F\u2580" + // 0xd8 - 0xdf
|
||||
"\u042F\u0440\u0420\u0441\u0421\u0442\u0422\u0443" + // 0xe0 - 0xe7
|
||||
"\u0423\u0436\u0416\u0432\u0412\u044C\u042C\u2116" + // 0xe8 - 0xef
|
||||
"\u00AD\u044B\u042B\u0437\u0417\u0448\u0428\u044D" + // 0xf0 - 0xf7
|
||||
"\u042D\u0449\u0429\u0447\u0427\u00A7\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM857.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM857.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM857 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM857() {
|
||||
super("IBM857", StandardCharsets.aliases_IBM857);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp857";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM857);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7" + // 0x80 - 0x87
|
||||
"\u00EA\u00EB\u00E8\u00EF\u00EE\u0131\u00C4\u00C5" + // 0x88 - 0x8f
|
||||
"\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9" + // 0x90 - 0x97
|
||||
"\u0130\u00D6\u00DC\u00F8\u00A3\u00D8\u015E\u015F" + // 0x98 - 0x9f
|
||||
"\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u011E\u011F" + // 0xa0 - 0xa7
|
||||
"\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0" + // 0xb0 - 0xb7
|
||||
"\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4" + // 0xc8 - 0xcf
|
||||
"\u00BA\u00AA\u00CA\u00CB\u00C8\uFFFD\u00CD\u00CE" + // 0xd0 - 0xd7
|
||||
"\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580" + // 0xd8 - 0xdf
|
||||
"\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\uFFFD" + // 0xe0 - 0xe7
|
||||
"\u00D7\u00DA\u00DB\u00D9\u00EC\u00FF\u00AF\u00B4" + // 0xe8 - 0xef
|
||||
"\u00AD\u00B1\uFFFD\u00BE\u00B6\u00A7\u00F7\u00B8" + // 0xf0 - 0xf7
|
||||
"\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM858.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM858.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM858 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM858() {
|
||||
super("IBM00858", StandardCharsets.aliases_IBM858);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp858";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM858);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00C7\u00FC\u00E9\u00E2\u00E4\u00E0\u00E5\u00E7" + // 0x80 - 0x87
|
||||
"\u00EA\u00EB\u00E8\u00EF\u00EE\u00EC\u00C4\u00C5" + // 0x88 - 0x8f
|
||||
"\u00C9\u00E6\u00C6\u00F4\u00F6\u00F2\u00FB\u00F9" + // 0x90 - 0x97
|
||||
"\u00FF\u00D6\u00DC\u00F8\u00A3\u00D8\u00D7\u0192" + // 0x98 - 0x9f
|
||||
"\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA" + // 0xa0 - 0xa7
|
||||
"\u00BF\u00AE\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u00C1\u00C2\u00C0" + // 0xb0 - 0xb7
|
||||
"\u00A9\u2563\u2551\u2557\u255D\u00A2\u00A5\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u00E3\u00C3" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u00A4" + // 0xc8 - 0xcf
|
||||
"\u00F0\u00D0\u00CA\u00CB\u00C8\u20AC\u00CD\u00CE" + // 0xd0 - 0xd7
|
||||
"\u00CF\u2518\u250C\u2588\u2584\u00A6\u00CC\u2580" + // 0xd8 - 0xdf
|
||||
"\u00D3\u00DF\u00D4\u00D2\u00F5\u00D5\u00B5\u00FE" + // 0xe0 - 0xe7
|
||||
"\u00DE\u00DA\u00DB\u00D9\u00FD\u00DD\u00AF\u00B4" + // 0xe8 - 0xef
|
||||
"\u00AD\u00B1\u2017\u00BE\u00B6\u00A7\u00F7\u00B8" + // 0xf0 - 0xf7
|
||||
"\u00B0\u00A8\u00B7\u00B9\u00B3\u00B2\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM862.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM862.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM862 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM862() {
|
||||
super("IBM862", StandardCharsets.aliases_IBM862);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp862";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM862);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7" + // 0x80 - 0x87
|
||||
"\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF" + // 0x88 - 0x8f
|
||||
"\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7" + // 0x90 - 0x97
|
||||
"\u05E8\u05E9\u05EA\u00A2\u00A3\u00A5\u20A7\u0192" + // 0x98 - 0x9f
|
||||
"\u00E1\u00ED\u00F3\u00FA\u00F1\u00D1\u00AA\u00BA" + // 0xa0 - 0xa7
|
||||
"\u00BF\u2310\u00AC\u00BD\u00BC\u00A1\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556" + // 0xb0 - 0xb7
|
||||
"\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567" + // 0xc8 - 0xcf
|
||||
"\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B" + // 0xd0 - 0xd7
|
||||
"\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580" + // 0xd8 - 0xdf
|
||||
"\u03B1\u00DF\u0393\u03C0\u03A3\u03C3\u00B5\u03C4" + // 0xe0 - 0xe7
|
||||
"\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229" + // 0xe8 - 0xef
|
||||
"\u2261\u00B1\u2265\u2264\u2320\u2321\u00F7\u2248" + // 0xf0 - 0xf7
|
||||
"\u00B0\u2219\u00B7\u221A\u207F\u00B2\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x800];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/IBM866.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/IBM866.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM866 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM866() {
|
||||
super("IBM866", StandardCharsets.aliases_IBM866);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp866";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM866);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417" + // 0x80 - 0x87
|
||||
"\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F" + // 0x88 - 0x8f
|
||||
"\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427" + // 0x90 - 0x97
|
||||
"\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F" + // 0x98 - 0x9f
|
||||
"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437" + // 0xa0 - 0xa7
|
||||
"\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556" + // 0xb0 - 0xb7
|
||||
"\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567" + // 0xc8 - 0xcf
|
||||
"\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B" + // 0xd0 - 0xd7
|
||||
"\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580" + // 0xd8 - 0xdf
|
||||
"\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447" + // 0xe0 - 0xe7
|
||||
"\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F" + // 0xe8 - 0xef
|
||||
"\u0401\u0451\u0404\u0454\u0407\u0457\u040E\u045E" + // 0xf0 - 0xf7
|
||||
"\u00B0\u2219\u00B7\u221A\u2116\u00A4\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/sun/nio/cs/IBM874.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/IBM874.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM874 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM874() {
|
||||
super("x-IBM874", StandardCharsets.aliases_IBM874);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp874";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM874);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u20AC\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x80 - 0x87
|
||||
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x88 - 0x8f
|
||||
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x90 - 0x97
|
||||
"\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x98 - 0x9f
|
||||
"\u0E48\u0E01\u0E02\u0E03\u0E04\u0E05\u0E06\u0E07" + // 0xa0 - 0xa7
|
||||
"\u0E08\u0E09\u0E0A\u0E0B\u0E0C\u0E0D\u0E0E\u0E0F" + // 0xa8 - 0xaf
|
||||
"\u0E10\u0E11\u0E12\u0E13\u0E14\u0E15\u0E16\u0E17" + // 0xb0 - 0xb7
|
||||
"\u0E18\u0E19\u0E1A\u0E1B\u0E1C\u0E1D\u0E1E\u0E1F" + // 0xb8 - 0xbf
|
||||
"\u0E20\u0E21\u0E22\u0E23\u0E24\u0E25\u0E26\u0E27" + // 0xc0 - 0xc7
|
||||
"\u0E28\u0E29\u0E2A\u0E2B\u0E2C\u0E2D\u0E2E\u0E2F" + // 0xc8 - 0xcf
|
||||
"\u0E30\u0E31\u0E32\u0E33\u0E34\u0E35\u0E36\u0E37" + // 0xd0 - 0xd7
|
||||
"\u0E38\u0E39\u0E3A\u0E49\u0E4A\u0E4B\u0E4C\u0E3F" + // 0xd8 - 0xdf
|
||||
"\u0E40\u0E41\u0E42\u0E43\u0E44\u0E45\u0E46\u0E47" + // 0xe0 - 0xe7
|
||||
"\u0E48\u0E49\u0E4A\u0E4B\u0E4C\u0E4D\u0E4E\u0E4F" + // 0xe8 - 0xef
|
||||
"\u0E50\u0E51\u0E52\u0E53\u0E54\u0E55\u0E56\u0E57" + // 0xf0 - 0xf7
|
||||
"\u0E58\u0E59\u0E5A\u0E5B\u00A2\u00AC\u00A6\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[32] = UNMAPPABLE_DECODING;
|
||||
b2cMap[91] = UNMAPPABLE_DECODING;
|
||||
b2cMap[92] = UNMAPPABLE_DECODING;
|
||||
b2cMap[93] = UNMAPPABLE_DECODING;
|
||||
b2cMap[94] = UNMAPPABLE_DECODING;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
265
jdkSrc/jdk8/sun/nio/cs/ISO_8859_1.java
Normal file
265
jdkSrc/jdk8/sun/nio/cs/ISO_8859_1.java
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.Arrays;
|
||||
|
||||
class ISO_8859_1
|
||||
extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
|
||||
public ISO_8859_1() {
|
||||
super("ISO-8859-1", StandardCharsets.aliases_ISO_8859_1);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_1";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs instanceof US_ASCII)
|
||||
|| (cs instanceof ISO_8859_1));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends CharsetDecoder
|
||||
implements ArrayDecoder {
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
assert (sp <= sl);
|
||||
sp = (sp <= sl ? sp : sl);
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
byte b = sa[sp];
|
||||
if (dp >= dl)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (char)(b & 0xff);
|
||||
sp++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
byte b = src.get();
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((char)(b & 0xff));
|
||||
mark++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
public int decode(byte[] src, int sp, int len, char[] dst) {
|
||||
if (len > dst.length)
|
||||
len = dst.length;
|
||||
int dp = 0;
|
||||
while (dp < len)
|
||||
dst[dp++] = (char)(src[sp++] & 0xff);
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder {
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return c <= '\u00FF';
|
||||
}
|
||||
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return true; // we accept any byte value
|
||||
}
|
||||
|
||||
private final Surrogate.Parser sgp = new Surrogate.Parser();
|
||||
|
||||
// JVM may replace this method with intrinsic code.
|
||||
// don't pass len value <= 0
|
||||
private static int encodeISOArray(char[] sa, int sp,
|
||||
byte[] da, int dp, int len)
|
||||
{
|
||||
int i = 0;
|
||||
for (; i < len; i++) {
|
||||
char c = sa[sp++];
|
||||
if (c > '\u00FF')
|
||||
break;
|
||||
da[dp++] = (byte)c;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private CoderResult encodeArrayLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
char[] sa = src.array();
|
||||
int soff = src.arrayOffset();
|
||||
int sp = soff + src.position();
|
||||
int sl = soff + src.limit();
|
||||
assert (sp <= sl);
|
||||
sp = (sp <= sl ? sp : sl);
|
||||
byte[] da = dst.array();
|
||||
int doff = dst.arrayOffset();
|
||||
int dp = doff + dst.position();
|
||||
int dl = doff + dst.limit();
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
int dlen = dl - dp;
|
||||
int slen = sl - sp;
|
||||
int len = (dlen < slen) ? dlen : slen;
|
||||
try {
|
||||
int ret = (len <= 0) ? 0 : encodeISOArray(sa, sp, da, dp, len);
|
||||
sp = sp + ret;
|
||||
dp = dp + ret;
|
||||
if (ret != len) {
|
||||
if (sgp.parse(sa[sp], sa, sp, sl) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
if (len < slen)
|
||||
return CoderResult.OVERFLOW;
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - soff);
|
||||
dst.position(dp - doff);
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (c <= '\u00FF') {
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)c);
|
||||
mark++;
|
||||
continue;
|
||||
}
|
||||
if (sgp.parse(c, src) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private byte repl = (byte)'?';
|
||||
protected void implReplaceWith(byte[] newReplacement) {
|
||||
repl = newReplacement[0];
|
||||
}
|
||||
|
||||
public int encode(char[] src, int sp, int len, byte[] dst) {
|
||||
int dp = 0;
|
||||
int slen = Math.min(len, dst.length);
|
||||
int sl = sp + slen;
|
||||
while (sp < sl) {
|
||||
int ret =
|
||||
(slen <= 0) ? 0 : encodeISOArray(src, sp, dst, dp, slen);
|
||||
sp = sp + ret;
|
||||
dp = dp + ret;
|
||||
if (ret != slen) {
|
||||
char c = src[sp++];
|
||||
if (Character.isHighSurrogate(c) && sp < sl &&
|
||||
Character.isLowSurrogate(src[sp])) {
|
||||
if (len > dst.length) {
|
||||
sl++;
|
||||
len--;
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
dst[dp++] = repl;
|
||||
slen = Math.min((sl - sp), (dst.length - dp));
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_13.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_13.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class ISO_8859_13 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public ISO_8859_13() {
|
||||
super("ISO-8859-13", StandardCharsets.aliases_ISO_8859_13);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_13";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof ISO_8859_13));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u201D\u00A2\u00A3\u00A4\u201E\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00D8\u00A9\u0156\u00AB\u00AC\u00AD\u00AE\u00C6" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u201C\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u00F8\u00B9\u0157\u00BB\u00BC\u00BD\u00BE\u00E6" + // 0xb8 - 0xbf
|
||||
"\u0104\u012E\u0100\u0106\u00C4\u00C5\u0118\u0112" + // 0xc0 - 0xc7
|
||||
"\u010C\u00C9\u0179\u0116\u0122\u0136\u012A\u013B" + // 0xc8 - 0xcf
|
||||
"\u0160\u0143\u0145\u00D3\u014C\u00D5\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u0172\u0141\u015A\u016A\u00DC\u017B\u017D\u00DF" + // 0xd8 - 0xdf
|
||||
"\u0105\u012F\u0101\u0107\u00E4\u00E5\u0119\u0113" + // 0xe0 - 0xe7
|
||||
"\u010D\u00E9\u017A\u0117\u0123\u0137\u012B\u013C" + // 0xe8 - 0xef
|
||||
"\u0161\u0144\u0146\u00F3\u014D\u00F5\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u0173\u0142\u015B\u016B\u00FC\u017C\u017E\u2019" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_15.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_15.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class ISO_8859_15 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public ISO_8859_15() {
|
||||
super("ISO-8859-15", StandardCharsets.aliases_ISO_8859_15);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_15";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof ISO_8859_15));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u00A1\u00A2\u00A3\u20AC\u00A5\u0160\u00A7" + // 0xa0 - 0xa7
|
||||
"\u0161\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u017D\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u017E\u00B9\u00BA\u00BB\u0152\u0153\u0178\u00BF" + // 0xb8 - 0xbf
|
||||
"\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7" + // 0xc0 - 0xc7
|
||||
"\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF" + // 0xc8 - 0xcf
|
||||
"\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF" + // 0xd8 - 0xdf
|
||||
"\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7" + // 0xe0 - 0xe7
|
||||
"\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF" + // 0xe8 - 0xef
|
||||
"\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_2.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_2.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class ISO_8859_2 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public ISO_8859_2() {
|
||||
super("ISO-8859-2", StandardCharsets.aliases_ISO_8859_2);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_2";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof ISO_8859_2));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u0104\u02D8\u0141\u00A4\u013D\u015A\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u0160\u015E\u0164\u0179\u00AD\u017D\u017B" + // 0xa8 - 0xaf
|
||||
"\u00B0\u0105\u02DB\u0142\u00B4\u013E\u015B\u02C7" + // 0xb0 - 0xb7
|
||||
"\u00B8\u0161\u015F\u0165\u017A\u02DD\u017E\u017C" + // 0xb8 - 0xbf
|
||||
"\u0154\u00C1\u00C2\u0102\u00C4\u0139\u0106\u00C7" + // 0xc0 - 0xc7
|
||||
"\u010C\u00C9\u0118\u00CB\u011A\u00CD\u00CE\u010E" + // 0xc8 - 0xcf
|
||||
"\u0110\u0143\u0147\u00D3\u00D4\u0150\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u0158\u016E\u00DA\u0170\u00DC\u00DD\u0162\u00DF" + // 0xd8 - 0xdf
|
||||
"\u0155\u00E1\u00E2\u0103\u00E4\u013A\u0107\u00E7" + // 0xe0 - 0xe7
|
||||
"\u010D\u00E9\u0119\u00EB\u011B\u00ED\u00EE\u010F" + // 0xe8 - 0xef
|
||||
"\u0111\u0144\u0148\u00F3\u00F4\u0151\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u0159\u016F\u00FA\u0171\u00FC\u00FD\u0163\u02D9" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_4.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_4.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class ISO_8859_4 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public ISO_8859_4() {
|
||||
super("ISO-8859-4", StandardCharsets.aliases_ISO_8859_4);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_4";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof ISO_8859_4));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u0104\u0138\u0156\u00A4\u0128\u013B\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u0160\u0112\u0122\u0166\u00AD\u017D\u00AF" + // 0xa8 - 0xaf
|
||||
"\u00B0\u0105\u02DB\u0157\u00B4\u0129\u013C\u02C7" + // 0xb0 - 0xb7
|
||||
"\u00B8\u0161\u0113\u0123\u0167\u014A\u017E\u014B" + // 0xb8 - 0xbf
|
||||
"\u0100\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u012E" + // 0xc0 - 0xc7
|
||||
"\u010C\u00C9\u0118\u00CB\u0116\u00CD\u00CE\u012A" + // 0xc8 - 0xcf
|
||||
"\u0110\u0145\u014C\u0136\u00D4\u00D5\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u00D8\u0172\u00DA\u00DB\u00DC\u0168\u016A\u00DF" + // 0xd8 - 0xdf
|
||||
"\u0101\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u012F" + // 0xe0 - 0xe7
|
||||
"\u010D\u00E9\u0119\u00EB\u0117\u00ED\u00EE\u012B" + // 0xe8 - 0xef
|
||||
"\u0111\u0146\u014D\u0137\u00F4\u00F5\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u00F8\u0173\u00FA\u00FB\u00FC\u0169\u016B\u02D9" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_5.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_5.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class ISO_8859_5 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public ISO_8859_5() {
|
||||
super("ISO-8859-5", StandardCharsets.aliases_ISO_8859_5);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_5";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof ISO_8859_5));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u0401\u0402\u0403\u0404\u0405\u0406\u0407" + // 0xa0 - 0xa7
|
||||
"\u0408\u0409\u040A\u040B\u040C\u00AD\u040E\u040F" + // 0xa8 - 0xaf
|
||||
"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417" + // 0xb0 - 0xb7
|
||||
"\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F" + // 0xb8 - 0xbf
|
||||
"\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427" + // 0xc0 - 0xc7
|
||||
"\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F" + // 0xc8 - 0xcf
|
||||
"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437" + // 0xd0 - 0xd7
|
||||
"\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F" + // 0xd8 - 0xdf
|
||||
"\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447" + // 0xe0 - 0xe7
|
||||
"\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F" + // 0xe8 - 0xef
|
||||
"\u2116\u0451\u0452\u0453\u0454\u0455\u0456\u0457" + // 0xf0 - 0xf7
|
||||
"\u0458\u0459\u045A\u045B\u045C\u00A7\u045E\u045F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_7.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_7.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class ISO_8859_7 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public ISO_8859_7() {
|
||||
super("ISO-8859-7", StandardCharsets.aliases_ISO_8859_7);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_7";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof ISO_8859_7));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u2018\u2019\u00A3\u20AC\u20AF\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u00A9\u037A\u00AB\u00AC\u00AD\uFFFD\u2015" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u0384\u0385\u0386\u00B7" + // 0xb0 - 0xb7
|
||||
"\u0388\u0389\u038A\u00BB\u038C\u00BD\u038E\u038F" + // 0xb8 - 0xbf
|
||||
"\u0390\u0391\u0392\u0393\u0394\u0395\u0396\u0397" + // 0xc0 - 0xc7
|
||||
"\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F" + // 0xc8 - 0xcf
|
||||
"\u03A0\u03A1\uFFFD\u03A3\u03A4\u03A5\u03A6\u03A7" + // 0xd0 - 0xd7
|
||||
"\u03A8\u03A9\u03AA\u03AB\u03AC\u03AD\u03AE\u03AF" + // 0xd8 - 0xdf
|
||||
"\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7" + // 0xe0 - 0xe7
|
||||
"\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF" + // 0xe8 - 0xef
|
||||
"\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7" + // 0xf0 - 0xf7
|
||||
"\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\uFFFD" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_9.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ISO_8859_9.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class ISO_8859_9 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public ISO_8859_9() {
|
||||
super("ISO-8859-9", StandardCharsets.aliases_ISO_8859_9);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ISO8859_9";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof ISO_8859_9));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF" + // 0xb8 - 0xbf
|
||||
"\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7" + // 0xc0 - 0xc7
|
||||
"\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF" + // 0xc8 - 0xcf
|
||||
"\u011E\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u00D8\u00D9\u00DA\u00DB\u00DC\u0130\u015E\u00DF" + // 0xd8 - 0xdf
|
||||
"\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7" + // 0xe0 - 0xe7
|
||||
"\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF" + // 0xe8 - 0xef
|
||||
"\u011F\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u00F8\u00F9\u00FA\u00FB\u00FC\u0131\u015F\u00FF" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/KOI8_R.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/KOI8_R.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class KOI8_R extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public KOI8_R() {
|
||||
super("KOI8-R", StandardCharsets.aliases_KOI8_R);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "KOI8_R";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof KOI8_R));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524" + // 0x80 - 0x87
|
||||
"\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590" + // 0x88 - 0x8f
|
||||
"\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248" + // 0x90 - 0x97
|
||||
"\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7" + // 0x98 - 0x9f
|
||||
"\u2550\u2551\u2552\u0451\u2553\u2554\u2555\u2556" + // 0xa0 - 0xa7
|
||||
"\u2557\u2558\u2559\u255A\u255B\u255C\u255D\u255E" + // 0xa8 - 0xaf
|
||||
"\u255F\u2560\u2561\u0401\u2562\u2563\u2564\u2565" + // 0xb0 - 0xb7
|
||||
"\u2566\u2567\u2568\u2569\u256A\u256B\u256C\u00A9" + // 0xb8 - 0xbf
|
||||
"\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433" + // 0xc0 - 0xc7
|
||||
"\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E" + // 0xc8 - 0xcf
|
||||
"\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432" + // 0xd0 - 0xd7
|
||||
"\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A" + // 0xd8 - 0xdf
|
||||
"\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413" + // 0xe0 - 0xe7
|
||||
"\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E" + // 0xe8 - 0xef
|
||||
"\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412" + // 0xf0 - 0xf7
|
||||
"\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/KOI8_U.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/KOI8_U.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class KOI8_U extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public KOI8_U() {
|
||||
super("KOI8-U", StandardCharsets.aliases_KOI8_U);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "KOI8_U";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof KOI8_U));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524" + // 0x80 - 0x87
|
||||
"\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590" + // 0x88 - 0x8f
|
||||
"\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248" + // 0x90 - 0x97
|
||||
"\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7" + // 0x98 - 0x9f
|
||||
"\u2550\u2551\u2552\u0451\u0454\u2554\u0456\u0457" + // 0xa0 - 0xa7
|
||||
"\u2557\u2558\u2559\u255A\u255B\u0491\u255D\u255E" + // 0xa8 - 0xaf
|
||||
"\u255F\u2560\u2561\u0401\u0404\u2563\u0406\u0407" + // 0xb0 - 0xb7
|
||||
"\u2566\u2567\u2568\u2569\u256A\u0490\u256C\u00A9" + // 0xb8 - 0xbf
|
||||
"\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433" + // 0xc0 - 0xc7
|
||||
"\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E" + // 0xc8 - 0xcf
|
||||
"\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432" + // 0xd0 - 0xd7
|
||||
"\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A" + // 0xd8 - 0xdf
|
||||
"\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413" + // 0xe0 - 0xe7
|
||||
"\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E" + // 0xe8 - 0xef
|
||||
"\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412" + // 0xf0 - 0xf7
|
||||
"\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/MS1250.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/MS1250.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class MS1250 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public MS1250() {
|
||||
super("windows-1250", StandardCharsets.aliases_MS1250);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1250";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof MS1250));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u20AC\uFFFD\u201A\uFFFD\u201E\u2026\u2020\u2021" + // 0x80 - 0x87
|
||||
"\uFFFD\u2030\u0160\u2039\u015A\u0164\u017D\u0179" + // 0x88 - 0x8f
|
||||
"\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014" + // 0x90 - 0x97
|
||||
"\uFFFD\u2122\u0161\u203A\u015B\u0165\u017E\u017A" + // 0x98 - 0x9f
|
||||
"\u00A0\u02C7\u02D8\u0141\u00A4\u0104\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u00A9\u015E\u00AB\u00AC\u00AD\u00AE\u017B" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u02DB\u0142\u00B4\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u00B8\u0105\u015F\u00BB\u013D\u02DD\u013E\u017C" + // 0xb8 - 0xbf
|
||||
"\u0154\u00C1\u00C2\u0102\u00C4\u0139\u0106\u00C7" + // 0xc0 - 0xc7
|
||||
"\u010C\u00C9\u0118\u00CB\u011A\u00CD\u00CE\u010E" + // 0xc8 - 0xcf
|
||||
"\u0110\u0143\u0147\u00D3\u00D4\u0150\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u0158\u016E\u00DA\u0170\u00DC\u00DD\u0162\u00DF" + // 0xd8 - 0xdf
|
||||
"\u0155\u00E1\u00E2\u0103\u00E4\u013A\u0107\u00E7" + // 0xe0 - 0xe7
|
||||
"\u010D\u00E9\u0119\u00EB\u011B\u00ED\u00EE\u010F" + // 0xe8 - 0xef
|
||||
"\u0111\u0144\u0148\u00F3\u00F4\u0151\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u0159\u016F\u00FA\u0171\u00FC\u00FD\u0163\u02D9" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x600];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/MS1251.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/MS1251.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class MS1251 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public MS1251() {
|
||||
super("windows-1251", StandardCharsets.aliases_MS1251);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1251";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof MS1251));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0402\u0403\u201A\u0453\u201E\u2026\u2020\u2021" + // 0x80 - 0x87
|
||||
"\u20AC\u2030\u0409\u2039\u040A\u040C\u040B\u040F" + // 0x88 - 0x8f
|
||||
"\u0452\u2018\u2019\u201C\u201D\u2022\u2013\u2014" + // 0x90 - 0x97
|
||||
"\uFFFD\u2122\u0459\u203A\u045A\u045C\u045B\u045F" + // 0x98 - 0x9f
|
||||
"\u00A0\u040E\u045E\u0408\u00A4\u0490\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u0401\u00A9\u0404\u00AB\u00AC\u00AD\u00AE\u0407" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u0406\u0456\u0491\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u0451\u2116\u0454\u00BB\u0458\u0405\u0455\u0457" + // 0xb8 - 0xbf
|
||||
"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417" + // 0xc0 - 0xc7
|
||||
"\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F" + // 0xc8 - 0xcf
|
||||
"\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427" + // 0xd0 - 0xd7
|
||||
"\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F" + // 0xd8 - 0xdf
|
||||
"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437" + // 0xe0 - 0xe7
|
||||
"\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F" + // 0xe8 - 0xef
|
||||
"\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447" + // 0xf0 - 0xf7
|
||||
"\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/MS1252.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/MS1252.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class MS1252 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public MS1252() {
|
||||
super("windows-1252", StandardCharsets.aliases_MS1252);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1252";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof MS1252));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021" + // 0x80 - 0x87
|
||||
"\u02C6\u2030\u0160\u2039\u0152\uFFFD\u017D\uFFFD" + // 0x88 - 0x8f
|
||||
"\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014" + // 0x90 - 0x97
|
||||
"\u02DC\u2122\u0161\u203A\u0153\uFFFD\u017E\u0178" + // 0x98 - 0x9f
|
||||
"\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF" + // 0xb8 - 0xbf
|
||||
"\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7" + // 0xc0 - 0xc7
|
||||
"\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF" + // 0xc8 - 0xcf
|
||||
"\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u00D8\u00D9\u00DA\u00DB\u00DC\u00DD\u00DE\u00DF" + // 0xd8 - 0xdf
|
||||
"\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7" + // 0xe0 - 0xe7
|
||||
"\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF" + // 0xe8 - 0xef
|
||||
"\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u00F8\u00F9\u00FA\u00FB\u00FC\u00FD\u00FE\u00FF" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x600];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/MS1253.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/MS1253.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class MS1253 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public MS1253() {
|
||||
super("windows-1253", StandardCharsets.aliases_MS1253);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1253";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof MS1253));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021" + // 0x80 - 0x87
|
||||
"\uFFFD\u2030\uFFFD\u2039\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x88 - 0x8f
|
||||
"\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014" + // 0x90 - 0x97
|
||||
"\uFFFD\u2122\uFFFD\u203A\uFFFD\uFFFD\uFFFD\uFFFD" + // 0x98 - 0x9f
|
||||
"\u00A0\u0385\u0386\u00A3\u00A4\u00A5\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u00A9\uFFFD\u00AB\u00AC\u00AD\u00AE\u2015" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u0384\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u0388\u0389\u038A\u00BB\u038C\u00BD\u038E\u038F" + // 0xb8 - 0xbf
|
||||
"\u0390\u0391\u0392\u0393\u0394\u0395\u0396\u0397" + // 0xc0 - 0xc7
|
||||
"\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F" + // 0xc8 - 0xcf
|
||||
"\u03A0\u03A1\uFFFD\u03A3\u03A4\u03A5\u03A6\u03A7" + // 0xd0 - 0xd7
|
||||
"\u03A8\u03A9\u03AA\u03AB\u03AC\u03AD\u03AE\u03AF" + // 0xd8 - 0xdf
|
||||
"\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7" + // 0xe0 - 0xe7
|
||||
"\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF" + // 0xe8 - 0xef
|
||||
"\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7" + // 0xf0 - 0xf7
|
||||
"\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\uFFFD" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x600];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/MS1254.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/MS1254.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class MS1254 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public MS1254() {
|
||||
super("windows-1254", StandardCharsets.aliases_MS1254);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1254";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof MS1254));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u20AC\uFFFD\u201A\u0192\u201E\u2026\u2020\u2021" + // 0x80 - 0x87
|
||||
"\u02C6\u2030\u0160\u2039\u0152\uFFFD\uFFFD\uFFFD" + // 0x88 - 0x8f
|
||||
"\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014" + // 0x90 - 0x97
|
||||
"\u02DC\u2122\u0161\u203A\u0153\uFFFD\uFFFD\u0178" + // 0x98 - 0x9f
|
||||
"\u00A0\u00A1\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00A8\u00A9\u00AA\u00AB\u00AC\u00AD\u00AE\u00AF" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u00B8\u00B9\u00BA\u00BB\u00BC\u00BD\u00BE\u00BF" + // 0xb8 - 0xbf
|
||||
"\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7" + // 0xc0 - 0xc7
|
||||
"\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF" + // 0xc8 - 0xcf
|
||||
"\u011E\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u00D8\u00D9\u00DA\u00DB\u00DC\u0130\u015E\u00DF" + // 0xd8 - 0xdf
|
||||
"\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7" + // 0xe0 - 0xe7
|
||||
"\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF" + // 0xe8 - 0xef
|
||||
"\u011F\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u00F8\u00F9\u00FA\u00FB\u00FC\u0131\u015F\u00FF" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x600];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/MS1257.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/MS1257.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class MS1257 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public MS1257() {
|
||||
super("windows-1257", StandardCharsets.aliases_MS1257);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1257";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII")) || (cs instanceof MS1257));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u20AC\uFFFD\u201A\uFFFD\u201E\u2026\u2020\u2021" + // 0x80 - 0x87
|
||||
"\uFFFD\u2030\uFFFD\u2039\uFFFD\u00A8\u02C7\u00B8" + // 0x88 - 0x8f
|
||||
"\uFFFD\u2018\u2019\u201C\u201D\u2022\u2013\u2014" + // 0x90 - 0x97
|
||||
"\uFFFD\u2122\uFFFD\u203A\uFFFD\u00AF\u02DB\uFFFD" + // 0x98 - 0x9f
|
||||
"\u00A0\uFFFD\u00A2\u00A3\u00A4\uFFFD\u00A6\u00A7" + // 0xa0 - 0xa7
|
||||
"\u00D8\u00A9\u0156\u00AB\u00AC\u00AD\u00AE\u00C6" + // 0xa8 - 0xaf
|
||||
"\u00B0\u00B1\u00B2\u00B3\u00B4\u00B5\u00B6\u00B7" + // 0xb0 - 0xb7
|
||||
"\u00F8\u00B9\u0157\u00BB\u00BC\u00BD\u00BE\u00E6" + // 0xb8 - 0xbf
|
||||
"\u0104\u012E\u0100\u0106\u00C4\u00C5\u0118\u0112" + // 0xc0 - 0xc7
|
||||
"\u010C\u00C9\u0179\u0116\u0122\u0136\u012A\u013B" + // 0xc8 - 0xcf
|
||||
"\u0160\u0143\u0145\u00D3\u014C\u00D5\u00D6\u00D7" + // 0xd0 - 0xd7
|
||||
"\u0172\u0141\u015A\u016A\u00DC\u017B\u017D\u00DF" + // 0xd8 - 0xdf
|
||||
"\u0105\u012F\u0101\u0107\u00E4\u00E5\u0119\u0113" + // 0xe0 - 0xe7
|
||||
"\u010D\u00E9\u017A\u0117\u0123\u0137\u012B\u013C" + // 0xe8 - 0xef
|
||||
"\u0161\u0144\u0146\u00F3\u014D\u00F5\u00F6\u00F7" + // 0xf0 - 0xf7
|
||||
"\u0173\u0142\u015B\u016B\u00FC\u017C\u017E\u02D9" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x600];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
296
jdkSrc/jdk8/sun/nio/cs/SingleByte.java
Normal file
296
jdkSrc/jdk8/sun/nio/cs/SingleByte.java
Normal file
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.Arrays;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class SingleByte
|
||||
{
|
||||
private static final CoderResult withResult(CoderResult cr,
|
||||
Buffer src, int sp,
|
||||
Buffer dst, int dp)
|
||||
{
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
return cr;
|
||||
}
|
||||
|
||||
final public static class Decoder extends CharsetDecoder
|
||||
implements ArrayDecoder {
|
||||
private final char[] b2c;
|
||||
|
||||
public Decoder(Charset cs, char[] b2c) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
this.b2c = b2c;
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
CoderResult cr = CoderResult.UNDERFLOW;
|
||||
if ((dl - dp) < (sl - sp)) {
|
||||
sl = sp + (dl - dp);
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
while (sp < sl) {
|
||||
char c = decode(sa[sp]);
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
return withResult(CoderResult.unmappableForLength(1),
|
||||
src, sp, dst, dp);
|
||||
}
|
||||
da[dp++] = c;
|
||||
sp++;
|
||||
}
|
||||
return withResult(cr, src, sp, dst, dp);
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = decode(src.get());
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
return CoderResult.unmappableForLength(1);
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put(c);
|
||||
mark++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
public final char decode(int b) {
|
||||
return b2c[b + 128];
|
||||
}
|
||||
|
||||
private char repl = '\uFFFD';
|
||||
protected void implReplaceWith(String newReplacement) {
|
||||
repl = newReplacement.charAt(0);
|
||||
}
|
||||
|
||||
public int decode(byte[] src, int sp, int len, char[] dst) {
|
||||
if (len > dst.length)
|
||||
len = dst.length;
|
||||
int dp = 0;
|
||||
while (dp < len) {
|
||||
dst[dp] = decode(src[sp++]);
|
||||
if (dst[dp] == UNMAPPABLE_DECODING) {
|
||||
dst[dp] = repl;
|
||||
}
|
||||
dp++;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
final public static class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder {
|
||||
private Surrogate.Parser sgp;
|
||||
private final char[] c2b;
|
||||
private final char[] c2bIndex;
|
||||
|
||||
public Encoder(Charset cs, char[] c2b, char[] c2bIndex) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
this.c2b = c2b;
|
||||
this.c2bIndex = c2bIndex;
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return encode(c) != UNMAPPABLE_ENCODING;
|
||||
}
|
||||
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return ((repl.length == 1 && repl[0] == (byte)'?') ||
|
||||
super.isLegalReplacement(repl));
|
||||
}
|
||||
|
||||
private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
CoderResult cr = CoderResult.UNDERFLOW;
|
||||
if ((dl - dp) < (sl - sp)) {
|
||||
sl = sp + (dl - dp);
|
||||
cr = CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
int b = encode(c);
|
||||
if (b == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
if (sgp.parse(c, sa, sp, sl) < 0)
|
||||
return withResult(sgp.error(), src, sp, dst, dp);
|
||||
return withResult(sgp.unmappableResult(), src, sp, dst, dp);
|
||||
}
|
||||
return withResult(CoderResult.unmappableForLength(1),
|
||||
src, sp, dst, dp);
|
||||
}
|
||||
da[dp++] = (byte)b;
|
||||
sp++;
|
||||
}
|
||||
return withResult(cr, src, sp, dst, dp);
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
int b = encode(c);
|
||||
if (b == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
if (sgp.parse(c, src) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)b);
|
||||
mark++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
public final int encode(char ch) {
|
||||
char index = c2bIndex[ch >> 8];
|
||||
if (index == UNMAPPABLE_ENCODING)
|
||||
return UNMAPPABLE_ENCODING;
|
||||
return c2b[index + (ch & 0xff)];
|
||||
}
|
||||
|
||||
private byte repl = (byte)'?';
|
||||
protected void implReplaceWith(byte[] newReplacement) {
|
||||
repl = newReplacement[0];
|
||||
}
|
||||
|
||||
public int encode(char[] src, int sp, int len, byte[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + Math.min(len, dst.length);
|
||||
while (sp < sl) {
|
||||
char c = src[sp++];
|
||||
int b = encode(c);
|
||||
if (b != UNMAPPABLE_ENCODING) {
|
||||
dst[dp++] = (byte)b;
|
||||
continue;
|
||||
}
|
||||
if (Character.isHighSurrogate(c) && sp < sl &&
|
||||
Character.isLowSurrogate(src[sp])) {
|
||||
if (len > dst.length) {
|
||||
sl++;
|
||||
len--;
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
dst[dp++] = repl;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
// init the c2b and c2bIndex tables from b2c.
|
||||
public static void initC2B(char[] b2c, char[] c2bNR,
|
||||
char[] c2b, char[] c2bIndex) {
|
||||
for (int i = 0; i < c2bIndex.length; i++)
|
||||
c2bIndex[i] = UNMAPPABLE_ENCODING;
|
||||
for (int i = 0; i < c2b.length; i++)
|
||||
c2b[i] = UNMAPPABLE_ENCODING;
|
||||
int off = 0;
|
||||
for (int i = 0; i < b2c.length; i++) {
|
||||
char c = b2c[i];
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
continue;
|
||||
int index = (c >> 8);
|
||||
if (c2bIndex[index] == UNMAPPABLE_ENCODING) {
|
||||
c2bIndex[index] = (char)off;
|
||||
off += 0x100;
|
||||
}
|
||||
index = c2bIndex[index] + (c & 0xff);
|
||||
c2b[index] = (char)((i>=0x80)?(i-0x80):(i+0x80));
|
||||
}
|
||||
if (c2bNR != null) {
|
||||
// c-->b nr entries
|
||||
int i = 0;
|
||||
while (i < c2bNR.length) {
|
||||
char b = c2bNR[i++];
|
||||
char c = c2bNR[i++];
|
||||
int index = (c >> 8);
|
||||
if (c2bIndex[index] == UNMAPPABLE_ENCODING) {
|
||||
c2bIndex[index] = (char)off;
|
||||
off += 0x100;
|
||||
}
|
||||
index = c2bIndex[index] + (c & 0xff);
|
||||
c2b[index] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
714
jdkSrc/jdk8/sun/nio/cs/StandardCharsets.java
Normal file
714
jdkSrc/jdk8/sun/nio/cs/StandardCharsets.java
Normal file
@@ -0,0 +1,714 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// -- This file was mechanically generated: Do not edit! -- //
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.*;
|
||||
|
||||
|
||||
public class StandardCharsets
|
||||
extends FastCharsetProvider
|
||||
{
|
||||
|
||||
static final String[] aliases_US_ASCII = new String[] {
|
||||
"iso-ir-6",
|
||||
"ANSI_X3.4-1986",
|
||||
"ISO_646.irv:1991",
|
||||
"ASCII",
|
||||
"ISO646-US",
|
||||
"us",
|
||||
"IBM367",
|
||||
"cp367",
|
||||
"csASCII",
|
||||
"default",
|
||||
"646",
|
||||
"iso_646.irv:1983",
|
||||
"ANSI_X3.4-1968",
|
||||
"ascii7",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_8 = new String[] {
|
||||
"UTF8",
|
||||
"unicode-1-1-utf-8",
|
||||
};
|
||||
|
||||
static final String[] aliases_CESU_8 = new String[] {
|
||||
"CESU8",
|
||||
"csCESU-8",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_16 = new String[] {
|
||||
"UTF_16",
|
||||
"utf16",
|
||||
"unicode",
|
||||
"UnicodeBig",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_16BE = new String[] {
|
||||
"UTF_16BE",
|
||||
"ISO-10646-UCS-2",
|
||||
"X-UTF-16BE",
|
||||
"UnicodeBigUnmarked",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_16LE = new String[] {
|
||||
"UTF_16LE",
|
||||
"X-UTF-16LE",
|
||||
"UnicodeLittleUnmarked",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_16LE_BOM = new String[] {
|
||||
"UnicodeLittle",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_32 = new String[] {
|
||||
"UTF_32",
|
||||
"UTF32",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_32LE = new String[] {
|
||||
"UTF_32LE",
|
||||
"X-UTF-32LE",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_32BE = new String[] {
|
||||
"UTF_32BE",
|
||||
"X-UTF-32BE",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_32LE_BOM = new String[] {
|
||||
"UTF_32LE_BOM",
|
||||
"UTF-32LE-BOM",
|
||||
};
|
||||
|
||||
static final String[] aliases_UTF_32BE_BOM = new String[] {
|
||||
"UTF_32BE_BOM",
|
||||
"UTF-32BE-BOM",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_1 = new String[] {
|
||||
"iso-ir-100",
|
||||
"ISO_8859-1",
|
||||
"latin1",
|
||||
"l1",
|
||||
"IBM819",
|
||||
"cp819",
|
||||
"csISOLatin1",
|
||||
"819",
|
||||
"IBM-819",
|
||||
"ISO8859_1",
|
||||
"ISO_8859-1:1987",
|
||||
"ISO_8859_1",
|
||||
"8859_1",
|
||||
"ISO8859-1",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_2 = new String[] {
|
||||
"iso8859_2",
|
||||
"8859_2",
|
||||
"iso-ir-101",
|
||||
"ISO_8859-2",
|
||||
"ISO_8859-2:1987",
|
||||
"ISO8859-2",
|
||||
"latin2",
|
||||
"l2",
|
||||
"ibm912",
|
||||
"ibm-912",
|
||||
"cp912",
|
||||
"912",
|
||||
"csISOLatin2",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_4 = new String[] {
|
||||
"iso8859_4",
|
||||
"iso8859-4",
|
||||
"8859_4",
|
||||
"iso-ir-110",
|
||||
"ISO_8859-4",
|
||||
"ISO_8859-4:1988",
|
||||
"latin4",
|
||||
"l4",
|
||||
"ibm914",
|
||||
"ibm-914",
|
||||
"cp914",
|
||||
"914",
|
||||
"csISOLatin4",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_5 = new String[] {
|
||||
"iso8859_5",
|
||||
"8859_5",
|
||||
"iso-ir-144",
|
||||
"ISO_8859-5",
|
||||
"ISO_8859-5:1988",
|
||||
"ISO8859-5",
|
||||
"cyrillic",
|
||||
"ibm915",
|
||||
"ibm-915",
|
||||
"cp915",
|
||||
"915",
|
||||
"csISOLatinCyrillic",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_7 = new String[] {
|
||||
"iso8859_7",
|
||||
"8859_7",
|
||||
"iso-ir-126",
|
||||
"ISO_8859-7",
|
||||
"ISO_8859-7:1987",
|
||||
"ELOT_928",
|
||||
"ECMA-118",
|
||||
"greek",
|
||||
"greek8",
|
||||
"csISOLatinGreek",
|
||||
"sun_eu_greek",
|
||||
"ibm813",
|
||||
"ibm-813",
|
||||
"813",
|
||||
"cp813",
|
||||
"iso8859-7",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_9 = new String[] {
|
||||
"iso8859_9",
|
||||
"8859_9",
|
||||
"iso-ir-148",
|
||||
"ISO_8859-9",
|
||||
"ISO_8859-9:1989",
|
||||
"ISO8859-9",
|
||||
"latin5",
|
||||
"l5",
|
||||
"ibm920",
|
||||
"ibm-920",
|
||||
"920",
|
||||
"cp920",
|
||||
"csISOLatin5",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_13 = new String[] {
|
||||
"iso8859_13",
|
||||
"8859_13",
|
||||
"iso_8859-13",
|
||||
"ISO8859-13",
|
||||
};
|
||||
|
||||
static final String[] aliases_ISO_8859_15 = new String[] {
|
||||
"ISO_8859-15",
|
||||
"8859_15",
|
||||
"ISO-8859-15",
|
||||
"ISO8859_15",
|
||||
"ISO8859-15",
|
||||
"IBM923",
|
||||
"IBM-923",
|
||||
"cp923",
|
||||
"923",
|
||||
"LATIN0",
|
||||
"LATIN9",
|
||||
"L9",
|
||||
"csISOlatin0",
|
||||
"csISOlatin9",
|
||||
"ISO8859_15_FDIS",
|
||||
};
|
||||
|
||||
static final String[] aliases_KOI8_R = new String[] {
|
||||
"koi8_r",
|
||||
"koi8",
|
||||
"cskoi8r",
|
||||
};
|
||||
|
||||
static final String[] aliases_KOI8_U = new String[] {
|
||||
"koi8_u",
|
||||
};
|
||||
|
||||
static final String[] aliases_MS1250 = new String[] {
|
||||
"cp1250",
|
||||
"cp5346",
|
||||
};
|
||||
|
||||
static final String[] aliases_MS1251 = new String[] {
|
||||
"cp1251",
|
||||
"cp5347",
|
||||
"ansi-1251",
|
||||
};
|
||||
|
||||
static final String[] aliases_MS1252 = new String[] {
|
||||
"cp1252",
|
||||
"cp5348",
|
||||
};
|
||||
|
||||
static final String[] aliases_MS1253 = new String[] {
|
||||
"cp1253",
|
||||
"cp5349",
|
||||
};
|
||||
|
||||
static final String[] aliases_MS1254 = new String[] {
|
||||
"cp1254",
|
||||
"cp5350",
|
||||
};
|
||||
|
||||
static final String[] aliases_MS1257 = new String[] {
|
||||
"cp1257",
|
||||
"cp5353",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM437 = new String[] {
|
||||
"cp437",
|
||||
"ibm437",
|
||||
"ibm-437",
|
||||
"437",
|
||||
"cspc8codepage437",
|
||||
"windows-437",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM737 = new String[] {
|
||||
"cp737",
|
||||
"ibm737",
|
||||
"ibm-737",
|
||||
"737",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM775 = new String[] {
|
||||
"cp775",
|
||||
"ibm775",
|
||||
"ibm-775",
|
||||
"775",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM850 = new String[] {
|
||||
"cp850",
|
||||
"ibm-850",
|
||||
"ibm850",
|
||||
"850",
|
||||
"cspc850multilingual",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM852 = new String[] {
|
||||
"cp852",
|
||||
"ibm852",
|
||||
"ibm-852",
|
||||
"852",
|
||||
"csPCp852",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM855 = new String[] {
|
||||
"cp855",
|
||||
"ibm-855",
|
||||
"ibm855",
|
||||
"855",
|
||||
"cspcp855",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM857 = new String[] {
|
||||
"cp857",
|
||||
"ibm857",
|
||||
"ibm-857",
|
||||
"857",
|
||||
"csIBM857",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM858 = new String[] {
|
||||
"cp858",
|
||||
"ccsid00858",
|
||||
"cp00858",
|
||||
"858",
|
||||
"PC-Multilingual-850+euro",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM862 = new String[] {
|
||||
"cp862",
|
||||
"ibm862",
|
||||
"ibm-862",
|
||||
"862",
|
||||
"csIBM862",
|
||||
"cspc862latinhebrew",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM866 = new String[] {
|
||||
"cp866",
|
||||
"ibm866",
|
||||
"ibm-866",
|
||||
"866",
|
||||
"csIBM866",
|
||||
};
|
||||
|
||||
static final String[] aliases_IBM874 = new String[] {
|
||||
"cp874",
|
||||
"ibm874",
|
||||
"ibm-874",
|
||||
"874",
|
||||
};
|
||||
|
||||
private static final class Aliases
|
||||
extends sun.util.PreHashedMap<String>
|
||||
{
|
||||
|
||||
private static final int ROWS = 1024;
|
||||
private static final int SIZE = 211;
|
||||
private static final int SHIFT = 0;
|
||||
private static final int MASK = 0x3ff;
|
||||
|
||||
private Aliases() {
|
||||
super(ROWS, SIZE, SHIFT, MASK);
|
||||
}
|
||||
|
||||
protected void init(Object[] ht) {
|
||||
ht[1] = new Object[] { "csisolatin0", "iso-8859-15" };
|
||||
ht[2] = new Object[] { "csisolatin1", "iso-8859-1" };
|
||||
ht[3] = new Object[] { "csisolatin2", "iso-8859-2" };
|
||||
ht[5] = new Object[] { "csisolatin4", "iso-8859-4" };
|
||||
ht[6] = new Object[] { "csisolatin5", "iso-8859-9" };
|
||||
ht[10] = new Object[] { "csisolatin9", "iso-8859-15" };
|
||||
ht[19] = new Object[] { "unicodelittle", "x-utf-16le-bom" };
|
||||
ht[24] = new Object[] { "iso646-us", "us-ascii" };
|
||||
ht[25] = new Object[] { "iso_8859-7:1987", "iso-8859-7" };
|
||||
ht[26] = new Object[] { "912", "iso-8859-2" };
|
||||
ht[28] = new Object[] { "914", "iso-8859-4" };
|
||||
ht[29] = new Object[] { "915", "iso-8859-5" };
|
||||
ht[55] = new Object[] { "920", "iso-8859-9" };
|
||||
ht[58] = new Object[] { "923", "iso-8859-15" };
|
||||
ht[86] = new Object[] { "csisolatincyrillic", "iso-8859-5",
|
||||
new Object[] { "8859_1", "iso-8859-1" } };
|
||||
ht[87] = new Object[] { "8859_2", "iso-8859-2" };
|
||||
ht[89] = new Object[] { "8859_4", "iso-8859-4" };
|
||||
ht[90] = new Object[] { "813", "iso-8859-7",
|
||||
new Object[] { "8859_5", "iso-8859-5" } };
|
||||
ht[92] = new Object[] { "8859_7", "iso-8859-7" };
|
||||
ht[94] = new Object[] { "8859_9", "iso-8859-9" };
|
||||
ht[95] = new Object[] { "iso_8859-1:1987", "iso-8859-1" };
|
||||
ht[96] = new Object[] { "819", "iso-8859-1" };
|
||||
ht[106] = new Object[] { "unicode-1-1-utf-8", "utf-8" };
|
||||
ht[121] = new Object[] { "x-utf-16le", "utf-16le" };
|
||||
ht[125] = new Object[] { "ecma-118", "iso-8859-7" };
|
||||
ht[134] = new Object[] { "koi8_r", "koi8-r" };
|
||||
ht[137] = new Object[] { "koi8_u", "koi8-u" };
|
||||
ht[141] = new Object[] { "cp912", "iso-8859-2" };
|
||||
ht[143] = new Object[] { "cp914", "iso-8859-4" };
|
||||
ht[144] = new Object[] { "cp915", "iso-8859-5" };
|
||||
ht[170] = new Object[] { "cp920", "iso-8859-9" };
|
||||
ht[173] = new Object[] { "cp923", "iso-8859-15" };
|
||||
ht[177] = new Object[] { "utf_32le_bom", "x-utf-32le-bom" };
|
||||
ht[192] = new Object[] { "utf_16be", "utf-16be" };
|
||||
ht[199] = new Object[] { "cspc8codepage437", "ibm437",
|
||||
new Object[] { "ansi-1251", "windows-1251" } };
|
||||
ht[205] = new Object[] { "cp813", "iso-8859-7" };
|
||||
ht[211] = new Object[] { "850", "ibm850",
|
||||
new Object[] { "cp819", "iso-8859-1" } };
|
||||
ht[213] = new Object[] { "852", "ibm852" };
|
||||
ht[216] = new Object[] { "855", "ibm855" };
|
||||
ht[218] = new Object[] { "857", "ibm857",
|
||||
new Object[] { "iso-ir-6", "us-ascii" } };
|
||||
ht[219] = new Object[] { "858", "ibm00858",
|
||||
new Object[] { "737", "x-ibm737" } };
|
||||
ht[225] = new Object[] { "csascii", "us-ascii" };
|
||||
ht[244] = new Object[] { "862", "ibm862" };
|
||||
ht[248] = new Object[] { "866", "ibm866" };
|
||||
ht[253] = new Object[] { "x-utf-32be", "utf-32be" };
|
||||
ht[254] = new Object[] { "iso_8859-2:1987", "iso-8859-2" };
|
||||
ht[259] = new Object[] { "unicodebig", "utf-16" };
|
||||
ht[269] = new Object[] { "iso8859_15_fdis", "iso-8859-15" };
|
||||
ht[277] = new Object[] { "874", "x-ibm874" };
|
||||
ht[280] = new Object[] { "unicodelittleunmarked", "utf-16le" };
|
||||
ht[283] = new Object[] { "iso8859_1", "iso-8859-1" };
|
||||
ht[284] = new Object[] { "iso8859_2", "iso-8859-2" };
|
||||
ht[286] = new Object[] { "iso8859_4", "iso-8859-4" };
|
||||
ht[287] = new Object[] { "iso8859_5", "iso-8859-5" };
|
||||
ht[289] = new Object[] { "iso8859_7", "iso-8859-7" };
|
||||
ht[291] = new Object[] { "iso8859_9", "iso-8859-9" };
|
||||
ht[294] = new Object[] { "ibm912", "iso-8859-2" };
|
||||
ht[296] = new Object[] { "ibm914", "iso-8859-4" };
|
||||
ht[297] = new Object[] { "ibm915", "iso-8859-5" };
|
||||
ht[305] = new Object[] { "iso_8859-13", "iso-8859-13" };
|
||||
ht[307] = new Object[] { "iso_8859-15", "iso-8859-15" };
|
||||
ht[312] = new Object[] { "greek8", "iso-8859-7",
|
||||
new Object[] { "646", "us-ascii" } };
|
||||
ht[321] = new Object[] { "ibm-912", "iso-8859-2" };
|
||||
ht[323] = new Object[] { "ibm920", "iso-8859-9",
|
||||
new Object[] { "ibm-914", "iso-8859-4" } };
|
||||
ht[324] = new Object[] { "ibm-915", "iso-8859-5" };
|
||||
ht[325] = new Object[] { "l1", "iso-8859-1" };
|
||||
ht[326] = new Object[] { "cp850", "ibm850",
|
||||
new Object[] { "ibm923", "iso-8859-15",
|
||||
new Object[] { "l2", "iso-8859-2" } } };
|
||||
ht[327] = new Object[] { "cyrillic", "iso-8859-5" };
|
||||
ht[328] = new Object[] { "cp852", "ibm852",
|
||||
new Object[] { "l4", "iso-8859-4" } };
|
||||
ht[329] = new Object[] { "l5", "iso-8859-9" };
|
||||
ht[331] = new Object[] { "cp855", "ibm855" };
|
||||
ht[333] = new Object[] { "cp857", "ibm857",
|
||||
new Object[] { "l9", "iso-8859-15" } };
|
||||
ht[334] = new Object[] { "cp858", "ibm00858",
|
||||
new Object[] { "cp737", "x-ibm737" } };
|
||||
ht[336] = new Object[] { "iso_8859_1", "iso-8859-1" };
|
||||
ht[339] = new Object[] { "koi8", "koi8-r" };
|
||||
ht[341] = new Object[] { "775", "ibm775" };
|
||||
ht[345] = new Object[] { "iso_8859-9:1989", "iso-8859-9" };
|
||||
ht[350] = new Object[] { "ibm-920", "iso-8859-9" };
|
||||
ht[353] = new Object[] { "ibm-923", "iso-8859-15" };
|
||||
ht[358] = new Object[] { "ibm813", "iso-8859-7" };
|
||||
ht[359] = new Object[] { "cp862", "ibm862" };
|
||||
ht[363] = new Object[] { "cp866", "ibm866" };
|
||||
ht[364] = new Object[] { "ibm819", "iso-8859-1" };
|
||||
ht[378] = new Object[] { "ansi_x3.4-1968", "us-ascii" };
|
||||
ht[385] = new Object[] { "ibm-813", "iso-8859-7" };
|
||||
ht[391] = new Object[] { "ibm-819", "iso-8859-1" };
|
||||
ht[392] = new Object[] { "cp874", "x-ibm874" };
|
||||
ht[405] = new Object[] { "iso-ir-100", "iso-8859-1" };
|
||||
ht[406] = new Object[] { "iso-ir-101", "iso-8859-2" };
|
||||
ht[408] = new Object[] { "437", "ibm437" };
|
||||
ht[421] = new Object[] { "iso-8859-15", "iso-8859-15" };
|
||||
ht[428] = new Object[] { "latin0", "iso-8859-15" };
|
||||
ht[429] = new Object[] { "latin1", "iso-8859-1" };
|
||||
ht[430] = new Object[] { "latin2", "iso-8859-2" };
|
||||
ht[432] = new Object[] { "latin4", "iso-8859-4" };
|
||||
ht[433] = new Object[] { "latin5", "iso-8859-9" };
|
||||
ht[436] = new Object[] { "iso-ir-110", "iso-8859-4" };
|
||||
ht[437] = new Object[] { "latin9", "iso-8859-15" };
|
||||
ht[438] = new Object[] { "ansi_x3.4-1986", "us-ascii" };
|
||||
ht[443] = new Object[] { "utf-32be-bom", "x-utf-32be-bom" };
|
||||
ht[456] = new Object[] { "cp775", "ibm775" };
|
||||
ht[473] = new Object[] { "iso-ir-126", "iso-8859-7" };
|
||||
ht[479] = new Object[] { "ibm850", "ibm850" };
|
||||
ht[481] = new Object[] { "ibm852", "ibm852" };
|
||||
ht[484] = new Object[] { "ibm855", "ibm855" };
|
||||
ht[486] = new Object[] { "ibm857", "ibm857" };
|
||||
ht[487] = new Object[] { "ibm737", "x-ibm737" };
|
||||
ht[502] = new Object[] { "utf_16le", "utf-16le" };
|
||||
ht[506] = new Object[] { "ibm-850", "ibm850" };
|
||||
ht[508] = new Object[] { "ibm-852", "ibm852" };
|
||||
ht[511] = new Object[] { "ibm-855", "ibm855" };
|
||||
ht[512] = new Object[] { "ibm862", "ibm862" };
|
||||
ht[513] = new Object[] { "ibm-857", "ibm857" };
|
||||
ht[514] = new Object[] { "ibm-737", "x-ibm737" };
|
||||
ht[516] = new Object[] { "ibm866", "ibm866" };
|
||||
ht[520] = new Object[] { "unicodebigunmarked", "utf-16be" };
|
||||
ht[523] = new Object[] { "cp437", "ibm437" };
|
||||
ht[524] = new Object[] { "utf16", "utf-16" };
|
||||
ht[533] = new Object[] { "iso-ir-144", "iso-8859-5" };
|
||||
ht[537] = new Object[] { "iso-ir-148", "iso-8859-9" };
|
||||
ht[539] = new Object[] { "ibm-862", "ibm862" };
|
||||
ht[543] = new Object[] { "ibm-866", "ibm866" };
|
||||
ht[545] = new Object[] { "ibm874", "x-ibm874" };
|
||||
ht[563] = new Object[] { "x-utf-32le", "utf-32le" };
|
||||
ht[572] = new Object[] { "ibm-874", "x-ibm874" };
|
||||
ht[573] = new Object[] { "iso_8859-4:1988", "iso-8859-4" };
|
||||
ht[577] = new Object[] { "default", "us-ascii" };
|
||||
ht[582] = new Object[] { "utf32", "utf-32" };
|
||||
ht[583] = new Object[] { "pc-multilingual-850+euro", "ibm00858" };
|
||||
ht[588] = new Object[] { "elot_928", "iso-8859-7" };
|
||||
ht[593] = new Object[] { "csisolatingreek", "iso-8859-7" };
|
||||
ht[598] = new Object[] { "csibm857", "ibm857" };
|
||||
ht[609] = new Object[] { "ibm775", "ibm775" };
|
||||
ht[617] = new Object[] { "cp1250", "windows-1250" };
|
||||
ht[618] = new Object[] { "cp1251", "windows-1251" };
|
||||
ht[619] = new Object[] { "cp1252", "windows-1252" };
|
||||
ht[620] = new Object[] { "cp1253", "windows-1253" };
|
||||
ht[621] = new Object[] { "cp1254", "windows-1254" };
|
||||
ht[624] = new Object[] { "csibm862", "ibm862",
|
||||
new Object[] { "cp1257", "windows-1257" } };
|
||||
ht[628] = new Object[] { "csibm866", "ibm866",
|
||||
new Object[] { "cesu8", "cesu-8" } };
|
||||
ht[632] = new Object[] { "iso8859_13", "iso-8859-13" };
|
||||
ht[634] = new Object[] { "iso8859_15", "iso-8859-15",
|
||||
new Object[] { "utf_32be", "utf-32be" } };
|
||||
ht[635] = new Object[] { "utf_32be_bom", "x-utf-32be-bom" };
|
||||
ht[636] = new Object[] { "ibm-775", "ibm775" };
|
||||
ht[654] = new Object[] { "cp00858", "ibm00858" };
|
||||
ht[669] = new Object[] { "8859_13", "iso-8859-13" };
|
||||
ht[670] = new Object[] { "us", "us-ascii" };
|
||||
ht[671] = new Object[] { "8859_15", "iso-8859-15" };
|
||||
ht[676] = new Object[] { "ibm437", "ibm437" };
|
||||
ht[679] = new Object[] { "cp367", "us-ascii" };
|
||||
ht[686] = new Object[] { "iso-10646-ucs-2", "utf-16be" };
|
||||
ht[703] = new Object[] { "ibm-437", "ibm437" };
|
||||
ht[710] = new Object[] { "iso8859-13", "iso-8859-13" };
|
||||
ht[712] = new Object[] { "iso8859-15", "iso-8859-15" };
|
||||
ht[732] = new Object[] { "iso_8859-5:1988", "iso-8859-5" };
|
||||
ht[733] = new Object[] { "unicode", "utf-16" };
|
||||
ht[768] = new Object[] { "greek", "iso-8859-7" };
|
||||
ht[774] = new Object[] { "ascii7", "us-ascii" };
|
||||
ht[781] = new Object[] { "iso8859-1", "iso-8859-1" };
|
||||
ht[782] = new Object[] { "iso8859-2", "iso-8859-2" };
|
||||
ht[783] = new Object[] { "cskoi8r", "koi8-r" };
|
||||
ht[784] = new Object[] { "iso8859-4", "iso-8859-4" };
|
||||
ht[785] = new Object[] { "iso8859-5", "iso-8859-5" };
|
||||
ht[787] = new Object[] { "iso8859-7", "iso-8859-7" };
|
||||
ht[789] = new Object[] { "iso8859-9", "iso-8859-9" };
|
||||
ht[813] = new Object[] { "ccsid00858", "ibm00858" };
|
||||
ht[818] = new Object[] { "cspc862latinhebrew", "ibm862" };
|
||||
ht[832] = new Object[] { "ibm367", "us-ascii" };
|
||||
ht[834] = new Object[] { "iso_8859-1", "iso-8859-1" };
|
||||
ht[835] = new Object[] { "iso_8859-2", "iso-8859-2",
|
||||
new Object[] { "x-utf-16be", "utf-16be" } };
|
||||
ht[836] = new Object[] { "sun_eu_greek", "iso-8859-7" };
|
||||
ht[837] = new Object[] { "iso_8859-4", "iso-8859-4" };
|
||||
ht[838] = new Object[] { "iso_8859-5", "iso-8859-5" };
|
||||
ht[840] = new Object[] { "cspcp852", "ibm852",
|
||||
new Object[] { "iso_8859-7", "iso-8859-7" } };
|
||||
ht[842] = new Object[] { "iso_8859-9", "iso-8859-9" };
|
||||
ht[843] = new Object[] { "cspcp855", "ibm855" };
|
||||
ht[846] = new Object[] { "windows-437", "ibm437" };
|
||||
ht[849] = new Object[] { "ascii", "us-ascii" };
|
||||
ht[863] = new Object[] { "cscesu-8", "cesu-8" };
|
||||
ht[881] = new Object[] { "utf8", "utf-8" };
|
||||
ht[896] = new Object[] { "iso_646.irv:1983", "us-ascii" };
|
||||
ht[909] = new Object[] { "cp5346", "windows-1250" };
|
||||
ht[910] = new Object[] { "cp5347", "windows-1251" };
|
||||
ht[911] = new Object[] { "cp5348", "windows-1252" };
|
||||
ht[912] = new Object[] { "cp5349", "windows-1253" };
|
||||
ht[925] = new Object[] { "iso_646.irv:1991", "us-ascii" };
|
||||
ht[934] = new Object[] { "cp5350", "windows-1254" };
|
||||
ht[937] = new Object[] { "cp5353", "windows-1257" };
|
||||
ht[944] = new Object[] { "utf_32le", "utf-32le" };
|
||||
ht[957] = new Object[] { "utf_16", "utf-16" };
|
||||
ht[993] = new Object[] { "cspc850multilingual", "ibm850" };
|
||||
ht[1009] = new Object[] { "utf-32le-bom", "x-utf-32le-bom" };
|
||||
ht[1015] = new Object[] { "utf_32", "utf-32" };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final class Classes
|
||||
extends sun.util.PreHashedMap<String>
|
||||
{
|
||||
|
||||
private static final int ROWS = 32;
|
||||
private static final int SIZE = 39;
|
||||
private static final int SHIFT = 1;
|
||||
private static final int MASK = 0x1f;
|
||||
|
||||
private Classes() {
|
||||
super(ROWS, SIZE, SHIFT, MASK);
|
||||
}
|
||||
|
||||
protected void init(Object[] ht) {
|
||||
ht[0] = new Object[] { "ibm862", "IBM862" };
|
||||
ht[2] = new Object[] { "ibm866", "IBM866",
|
||||
new Object[] { "utf-32", "UTF_32",
|
||||
new Object[] { "utf-16le", "UTF_16LE" } } };
|
||||
ht[3] = new Object[] { "windows-1251", "MS1251",
|
||||
new Object[] { "windows-1250", "MS1250" } };
|
||||
ht[4] = new Object[] { "windows-1253", "MS1253",
|
||||
new Object[] { "windows-1252", "MS1252",
|
||||
new Object[] { "utf-32be", "UTF_32BE" } } };
|
||||
ht[5] = new Object[] { "windows-1254", "MS1254",
|
||||
new Object[] { "utf-16", "UTF_16" } };
|
||||
ht[6] = new Object[] { "windows-1257", "MS1257" };
|
||||
ht[7] = new Object[] { "utf-16be", "UTF_16BE" };
|
||||
ht[8] = new Object[] { "iso-8859-2", "ISO_8859_2",
|
||||
new Object[] { "iso-8859-1", "ISO_8859_1" } };
|
||||
ht[9] = new Object[] { "iso-8859-4", "ISO_8859_4",
|
||||
new Object[] { "utf-8", "UTF_8" } };
|
||||
ht[10] = new Object[] { "iso-8859-5", "ISO_8859_5" };
|
||||
ht[11] = new Object[] { "x-ibm874", "IBM874",
|
||||
new Object[] { "iso-8859-7", "ISO_8859_7" } };
|
||||
ht[12] = new Object[] { "iso-8859-9", "ISO_8859_9" };
|
||||
ht[14] = new Object[] { "x-ibm737", "IBM737" };
|
||||
ht[15] = new Object[] { "ibm850", "IBM850" };
|
||||
ht[16] = new Object[] { "ibm852", "IBM852",
|
||||
new Object[] { "ibm775", "IBM775" } };
|
||||
ht[17] = new Object[] { "iso-8859-13", "ISO_8859_13",
|
||||
new Object[] { "us-ascii", "US_ASCII" } };
|
||||
ht[18] = new Object[] { "ibm855", "IBM855",
|
||||
new Object[] { "ibm437", "IBM437",
|
||||
new Object[] { "iso-8859-15", "ISO_8859_15" } } };
|
||||
ht[19] = new Object[] { "ibm00858", "IBM858",
|
||||
new Object[] { "ibm857", "IBM857",
|
||||
new Object[] { "x-utf-32le-bom", "UTF_32LE_BOM" } } };
|
||||
ht[22] = new Object[] { "x-utf-16le-bom", "UTF_16LE_BOM" };
|
||||
ht[23] = new Object[] { "cesu-8", "CESU_8" };
|
||||
ht[24] = new Object[] { "x-utf-32be-bom", "UTF_32BE_BOM" };
|
||||
ht[28] = new Object[] { "koi8-r", "KOI8_R" };
|
||||
ht[29] = new Object[] { "koi8-u", "KOI8_U" };
|
||||
ht[31] = new Object[] { "utf-32le", "UTF_32LE" };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final class Cache
|
||||
extends sun.util.PreHashedMap<Charset>
|
||||
{
|
||||
|
||||
private static final int ROWS = 32;
|
||||
private static final int SIZE = 39;
|
||||
private static final int SHIFT = 1;
|
||||
private static final int MASK = 0x1f;
|
||||
|
||||
private Cache() {
|
||||
super(ROWS, SIZE, SHIFT, MASK);
|
||||
}
|
||||
|
||||
protected void init(Object[] ht) {
|
||||
ht[0] = new Object[] { "ibm862", null };
|
||||
ht[2] = new Object[] { "ibm866", null,
|
||||
new Object[] { "utf-32", null,
|
||||
new Object[] { "utf-16le", null } } };
|
||||
ht[3] = new Object[] { "windows-1251", null,
|
||||
new Object[] { "windows-1250", null } };
|
||||
ht[4] = new Object[] { "windows-1253", null,
|
||||
new Object[] { "windows-1252", null,
|
||||
new Object[] { "utf-32be", null } } };
|
||||
ht[5] = new Object[] { "windows-1254", null,
|
||||
new Object[] { "utf-16", null } };
|
||||
ht[6] = new Object[] { "windows-1257", null };
|
||||
ht[7] = new Object[] { "utf-16be", null };
|
||||
ht[8] = new Object[] { "iso-8859-2", null,
|
||||
new Object[] { "iso-8859-1", null } };
|
||||
ht[9] = new Object[] { "iso-8859-4", null,
|
||||
new Object[] { "utf-8", null } };
|
||||
ht[10] = new Object[] { "iso-8859-5", null };
|
||||
ht[11] = new Object[] { "x-ibm874", null,
|
||||
new Object[] { "iso-8859-7", null } };
|
||||
ht[12] = new Object[] { "iso-8859-9", null };
|
||||
ht[14] = new Object[] { "x-ibm737", null };
|
||||
ht[15] = new Object[] { "ibm850", null };
|
||||
ht[16] = new Object[] { "ibm852", null,
|
||||
new Object[] { "ibm775", null } };
|
||||
ht[17] = new Object[] { "iso-8859-13", null,
|
||||
new Object[] { "us-ascii", null } };
|
||||
ht[18] = new Object[] { "ibm855", null,
|
||||
new Object[] { "ibm437", null,
|
||||
new Object[] { "iso-8859-15", null } } };
|
||||
ht[19] = new Object[] { "ibm00858", null,
|
||||
new Object[] { "ibm857", null,
|
||||
new Object[] { "x-utf-32le-bom", null } } };
|
||||
ht[22] = new Object[] { "x-utf-16le-bom", null };
|
||||
ht[23] = new Object[] { "cesu-8", null };
|
||||
ht[24] = new Object[] { "x-utf-32be-bom", null };
|
||||
ht[28] = new Object[] { "koi8-r", null };
|
||||
ht[29] = new Object[] { "koi8-u", null };
|
||||
ht[31] = new Object[] { "utf-32le", null };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public StandardCharsets() {
|
||||
super("sun.nio.cs", new Aliases(), new Classes(), new Cache());
|
||||
}
|
||||
|
||||
}
|
||||
381
jdkSrc/jdk8/sun/nio/cs/StreamDecoder.java
Normal file
381
jdkSrc/jdk8/sun/nio/cs/StreamDecoder.java
Normal file
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.charset.*;
|
||||
|
||||
public class StreamDecoder extends Reader
|
||||
{
|
||||
|
||||
private static final int MIN_BYTE_BUFFER_SIZE = 32;
|
||||
private static final int DEFAULT_BYTE_BUFFER_SIZE = 8192;
|
||||
|
||||
private volatile boolean isOpen = true;
|
||||
|
||||
private void ensureOpen() throws IOException {
|
||||
if (!isOpen)
|
||||
throw new IOException("Stream closed");
|
||||
}
|
||||
|
||||
// In order to handle surrogates properly we must never try to produce
|
||||
// fewer than two characters at a time. If we're only asked to return one
|
||||
// character then the other is saved here to be returned later.
|
||||
//
|
||||
private boolean haveLeftoverChar = false;
|
||||
private char leftoverChar;
|
||||
|
||||
|
||||
// Factories for java.io.InputStreamReader
|
||||
|
||||
public static StreamDecoder forInputStreamReader(InputStream in,
|
||||
Object lock,
|
||||
String charsetName)
|
||||
throws UnsupportedEncodingException
|
||||
{
|
||||
String csn = charsetName;
|
||||
if (csn == null)
|
||||
csn = Charset.defaultCharset().name();
|
||||
try {
|
||||
if (Charset.isSupported(csn))
|
||||
return new StreamDecoder(in, lock, Charset.forName(csn));
|
||||
} catch (IllegalCharsetNameException x) { }
|
||||
throw new UnsupportedEncodingException (csn);
|
||||
}
|
||||
|
||||
public static StreamDecoder forInputStreamReader(InputStream in,
|
||||
Object lock,
|
||||
Charset cs)
|
||||
{
|
||||
return new StreamDecoder(in, lock, cs);
|
||||
}
|
||||
|
||||
public static StreamDecoder forInputStreamReader(InputStream in,
|
||||
Object lock,
|
||||
CharsetDecoder dec)
|
||||
{
|
||||
return new StreamDecoder(in, lock, dec);
|
||||
}
|
||||
|
||||
|
||||
// Factory for java.nio.channels.Channels.newReader
|
||||
|
||||
public static StreamDecoder forDecoder(ReadableByteChannel ch,
|
||||
CharsetDecoder dec,
|
||||
int minBufferCap)
|
||||
{
|
||||
return new StreamDecoder(ch, dec, minBufferCap);
|
||||
}
|
||||
|
||||
|
||||
// -- Public methods corresponding to those in InputStreamReader --
|
||||
|
||||
// All synchronization and state/argument checking is done in these public
|
||||
// methods; the concrete stream-decoder subclasses defined below need not
|
||||
// do any such checking.
|
||||
|
||||
public String getEncoding() {
|
||||
if (isOpen())
|
||||
return encodingName();
|
||||
return null;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
return read0();
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
private int read0() throws IOException {
|
||||
synchronized (lock) {
|
||||
|
||||
// Return the leftover char, if there is one
|
||||
if (haveLeftoverChar) {
|
||||
haveLeftoverChar = false;
|
||||
return leftoverChar;
|
||||
}
|
||||
|
||||
// Convert more bytes
|
||||
char cb[] = new char[2];
|
||||
int n = read(cb, 0, 2);
|
||||
switch (n) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 2:
|
||||
leftoverChar = cb[1];
|
||||
haveLeftoverChar = true;
|
||||
// FALL THROUGH
|
||||
case 1:
|
||||
return cb[0];
|
||||
default:
|
||||
assert false : n;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int read(char cbuf[], int offset, int length) throws IOException {
|
||||
int off = offset;
|
||||
int len = length;
|
||||
synchronized (lock) {
|
||||
ensureOpen();
|
||||
if ((off < 0) || (off > cbuf.length) || (len < 0) ||
|
||||
((off + len) > cbuf.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
int n = 0;
|
||||
|
||||
if (haveLeftoverChar) {
|
||||
// Copy the leftover char into the buffer
|
||||
cbuf[off] = leftoverChar;
|
||||
off++; len--;
|
||||
haveLeftoverChar = false;
|
||||
n = 1;
|
||||
if ((len == 0) || !implReady())
|
||||
// Return now if this is all we can produce w/o blocking
|
||||
return n;
|
||||
}
|
||||
|
||||
if (len == 1) {
|
||||
// Treat single-character array reads just like read()
|
||||
int c = read0();
|
||||
if (c == -1)
|
||||
return (n == 0) ? -1 : n;
|
||||
cbuf[off] = (char)c;
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
return n + implRead(cbuf, off, off + len);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean ready() throws IOException {
|
||||
synchronized (lock) {
|
||||
ensureOpen();
|
||||
return haveLeftoverChar || implReady();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
synchronized (lock) {
|
||||
if (!isOpen)
|
||||
return;
|
||||
implClose();
|
||||
isOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
|
||||
// -- Charset-based stream decoder impl --
|
||||
|
||||
// In the early stages of the build we haven't yet built the NIO native
|
||||
// code, so guard against that by catching the first UnsatisfiedLinkError
|
||||
// and setting this flag so that later attempts fail quickly.
|
||||
//
|
||||
private static volatile boolean channelsAvailable = true;
|
||||
|
||||
private static FileChannel getChannel(FileInputStream in) {
|
||||
if (!channelsAvailable)
|
||||
return null;
|
||||
try {
|
||||
return in.getChannel();
|
||||
} catch (UnsatisfiedLinkError x) {
|
||||
channelsAvailable = false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Charset cs;
|
||||
private CharsetDecoder decoder;
|
||||
private ByteBuffer bb;
|
||||
|
||||
// Exactly one of these is non-null
|
||||
private InputStream in;
|
||||
private ReadableByteChannel ch;
|
||||
|
||||
StreamDecoder(InputStream in, Object lock, Charset cs) {
|
||||
this(in, lock,
|
||||
cs.newDecoder()
|
||||
.onMalformedInput(CodingErrorAction.REPLACE)
|
||||
.onUnmappableCharacter(CodingErrorAction.REPLACE));
|
||||
}
|
||||
|
||||
StreamDecoder(InputStream in, Object lock, CharsetDecoder dec) {
|
||||
super(lock);
|
||||
this.cs = dec.charset();
|
||||
this.decoder = dec;
|
||||
|
||||
// This path disabled until direct buffers are faster
|
||||
if (false && in instanceof FileInputStream) {
|
||||
ch = getChannel((FileInputStream)in);
|
||||
if (ch != null)
|
||||
bb = ByteBuffer.allocateDirect(DEFAULT_BYTE_BUFFER_SIZE);
|
||||
}
|
||||
if (ch == null) {
|
||||
this.in = in;
|
||||
this.ch = null;
|
||||
bb = ByteBuffer.allocate(DEFAULT_BYTE_BUFFER_SIZE);
|
||||
}
|
||||
bb.flip(); // So that bb is initially empty
|
||||
}
|
||||
|
||||
StreamDecoder(ReadableByteChannel ch, CharsetDecoder dec, int mbc) {
|
||||
this.in = null;
|
||||
this.ch = ch;
|
||||
this.decoder = dec;
|
||||
this.cs = dec.charset();
|
||||
this.bb = ByteBuffer.allocate(mbc < 0
|
||||
? DEFAULT_BYTE_BUFFER_SIZE
|
||||
: (mbc < MIN_BYTE_BUFFER_SIZE
|
||||
? MIN_BYTE_BUFFER_SIZE
|
||||
: mbc));
|
||||
bb.flip();
|
||||
}
|
||||
|
||||
private int readBytes() throws IOException {
|
||||
bb.compact();
|
||||
try {
|
||||
if (ch != null) {
|
||||
// Read from the channel
|
||||
int n = ch.read(bb);
|
||||
if (n < 0)
|
||||
return n;
|
||||
} else {
|
||||
// Read from the input stream, and then update the buffer
|
||||
int lim = bb.limit();
|
||||
int pos = bb.position();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
assert rem > 0;
|
||||
int n = in.read(bb.array(), bb.arrayOffset() + pos, rem);
|
||||
if (n < 0)
|
||||
return n;
|
||||
if (n == 0)
|
||||
throw new IOException("Underlying input stream returned zero bytes");
|
||||
assert (n <= rem) : "n = " + n + ", rem = " + rem;
|
||||
bb.position(pos + n);
|
||||
}
|
||||
} finally {
|
||||
// Flip even when an IOException is thrown,
|
||||
// otherwise the stream will stutter
|
||||
bb.flip();
|
||||
}
|
||||
|
||||
int rem = bb.remaining();
|
||||
assert (rem != 0) : rem;
|
||||
return rem;
|
||||
}
|
||||
|
||||
int implRead(char[] cbuf, int off, int end) throws IOException {
|
||||
|
||||
// In order to handle surrogate pairs, this method requires that
|
||||
// the invoker attempt to read at least two characters. Saving the
|
||||
// extra character, if any, at a higher level is easier than trying
|
||||
// to deal with it here.
|
||||
assert (end - off > 1);
|
||||
|
||||
CharBuffer cb = CharBuffer.wrap(cbuf, off, end - off);
|
||||
if (cb.position() != 0)
|
||||
// Ensure that cb[0] == cbuf[off]
|
||||
cb = cb.slice();
|
||||
|
||||
boolean eof = false;
|
||||
for (;;) {
|
||||
CoderResult cr = decoder.decode(bb, cb, eof);
|
||||
if (cr.isUnderflow()) {
|
||||
if (eof)
|
||||
break;
|
||||
if (!cb.hasRemaining())
|
||||
break;
|
||||
if ((cb.position() > 0) && !inReady())
|
||||
break; // Block at most once
|
||||
int n = readBytes();
|
||||
if (n < 0) {
|
||||
eof = true;
|
||||
if ((cb.position() == 0) && (!bb.hasRemaining()))
|
||||
break;
|
||||
decoder.reset();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (cr.isOverflow()) {
|
||||
assert cb.position() > 0;
|
||||
break;
|
||||
}
|
||||
cr.throwException();
|
||||
}
|
||||
|
||||
if (eof) {
|
||||
// ## Need to flush decoder
|
||||
decoder.reset();
|
||||
}
|
||||
|
||||
if (cb.position() == 0) {
|
||||
if (eof)
|
||||
return -1;
|
||||
assert false;
|
||||
}
|
||||
return cb.position();
|
||||
}
|
||||
|
||||
String encodingName() {
|
||||
return ((cs instanceof HistoricallyNamedCharset)
|
||||
? ((HistoricallyNamedCharset)cs).historicalName()
|
||||
: cs.name());
|
||||
}
|
||||
|
||||
private boolean inReady() {
|
||||
try {
|
||||
return (((in != null) && (in.available() > 0))
|
||||
|| (ch instanceof FileChannel)); // ## RBC.available()?
|
||||
} catch (IOException x) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean implReady() {
|
||||
return bb.hasRemaining() || inReady();
|
||||
}
|
||||
|
||||
void implClose() throws IOException {
|
||||
if (ch != null)
|
||||
ch.close();
|
||||
else
|
||||
in.close();
|
||||
}
|
||||
|
||||
}
|
||||
332
jdkSrc/jdk8/sun/nio/cs/StreamEncoder.java
Normal file
332
jdkSrc/jdk8/sun/nio/cs/StreamEncoder.java
Normal file
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.charset.*;
|
||||
|
||||
public class StreamEncoder extends Writer
|
||||
{
|
||||
|
||||
private static final int DEFAULT_BYTE_BUFFER_SIZE = 8192;
|
||||
|
||||
private volatile boolean isOpen = true;
|
||||
|
||||
private void ensureOpen() throws IOException {
|
||||
if (!isOpen)
|
||||
throw new IOException("Stream closed");
|
||||
}
|
||||
|
||||
// Factories for java.io.OutputStreamWriter
|
||||
public static StreamEncoder forOutputStreamWriter(OutputStream out,
|
||||
Object lock,
|
||||
String charsetName)
|
||||
throws UnsupportedEncodingException
|
||||
{
|
||||
String csn = charsetName;
|
||||
if (csn == null)
|
||||
csn = Charset.defaultCharset().name();
|
||||
try {
|
||||
if (Charset.isSupported(csn))
|
||||
return new StreamEncoder(out, lock, Charset.forName(csn));
|
||||
} catch (IllegalCharsetNameException x) { }
|
||||
throw new UnsupportedEncodingException (csn);
|
||||
}
|
||||
|
||||
public static StreamEncoder forOutputStreamWriter(OutputStream out,
|
||||
Object lock,
|
||||
Charset cs)
|
||||
{
|
||||
return new StreamEncoder(out, lock, cs);
|
||||
}
|
||||
|
||||
public static StreamEncoder forOutputStreamWriter(OutputStream out,
|
||||
Object lock,
|
||||
CharsetEncoder enc)
|
||||
{
|
||||
return new StreamEncoder(out, lock, enc);
|
||||
}
|
||||
|
||||
|
||||
// Factory for java.nio.channels.Channels.newWriter
|
||||
|
||||
public static StreamEncoder forEncoder(WritableByteChannel ch,
|
||||
CharsetEncoder enc,
|
||||
int minBufferCap)
|
||||
{
|
||||
return new StreamEncoder(ch, enc, minBufferCap);
|
||||
}
|
||||
|
||||
|
||||
// -- Public methods corresponding to those in OutputStreamWriter --
|
||||
|
||||
// All synchronization and state/argument checking is done in these public
|
||||
// methods; the concrete stream-encoder subclasses defined below need not
|
||||
// do any such checking.
|
||||
|
||||
public String getEncoding() {
|
||||
if (isOpen())
|
||||
return encodingName();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void flushBuffer() throws IOException {
|
||||
synchronized (lock) {
|
||||
if (isOpen())
|
||||
implFlushBuffer();
|
||||
else
|
||||
throw new IOException("Stream closed");
|
||||
}
|
||||
}
|
||||
|
||||
public void write(int c) throws IOException {
|
||||
char cbuf[] = new char[1];
|
||||
cbuf[0] = (char) c;
|
||||
write(cbuf, 0, 1);
|
||||
}
|
||||
|
||||
public void write(char cbuf[], int off, int len) throws IOException {
|
||||
synchronized (lock) {
|
||||
ensureOpen();
|
||||
if ((off < 0) || (off > cbuf.length) || (len < 0) ||
|
||||
((off + len) > cbuf.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return;
|
||||
}
|
||||
implWrite(cbuf, off, len);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String str, int off, int len) throws IOException {
|
||||
/* Check the len before creating a char buffer */
|
||||
if (len < 0)
|
||||
throw new IndexOutOfBoundsException();
|
||||
char cbuf[] = new char[len];
|
||||
str.getChars(off, off + len, cbuf, 0);
|
||||
write(cbuf, 0, len);
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
synchronized (lock) {
|
||||
ensureOpen();
|
||||
implFlush();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
synchronized (lock) {
|
||||
if (!isOpen)
|
||||
return;
|
||||
implClose();
|
||||
isOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
|
||||
// -- Charset-based stream encoder impl --
|
||||
|
||||
private Charset cs;
|
||||
private CharsetEncoder encoder;
|
||||
private ByteBuffer bb;
|
||||
|
||||
// Exactly one of these is non-null
|
||||
private final OutputStream out;
|
||||
private WritableByteChannel ch;
|
||||
|
||||
// Leftover first char in a surrogate pair
|
||||
private boolean haveLeftoverChar = false;
|
||||
private char leftoverChar;
|
||||
private CharBuffer lcb = null;
|
||||
|
||||
private StreamEncoder(OutputStream out, Object lock, Charset cs) {
|
||||
this(out, lock,
|
||||
cs.newEncoder()
|
||||
.onMalformedInput(CodingErrorAction.REPLACE)
|
||||
.onUnmappableCharacter(CodingErrorAction.REPLACE));
|
||||
}
|
||||
|
||||
private StreamEncoder(OutputStream out, Object lock, CharsetEncoder enc) {
|
||||
super(lock);
|
||||
this.out = out;
|
||||
this.ch = null;
|
||||
this.cs = enc.charset();
|
||||
this.encoder = enc;
|
||||
|
||||
// This path disabled until direct buffers are faster
|
||||
if (false && out instanceof FileOutputStream) {
|
||||
ch = ((FileOutputStream)out).getChannel();
|
||||
if (ch != null)
|
||||
bb = ByteBuffer.allocateDirect(DEFAULT_BYTE_BUFFER_SIZE);
|
||||
}
|
||||
if (ch == null) {
|
||||
bb = ByteBuffer.allocate(DEFAULT_BYTE_BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
private StreamEncoder(WritableByteChannel ch, CharsetEncoder enc, int mbc) {
|
||||
this.out = null;
|
||||
this.ch = ch;
|
||||
this.cs = enc.charset();
|
||||
this.encoder = enc;
|
||||
this.bb = ByteBuffer.allocate(mbc < 0
|
||||
? DEFAULT_BYTE_BUFFER_SIZE
|
||||
: mbc);
|
||||
}
|
||||
|
||||
private void writeBytes() throws IOException {
|
||||
bb.flip();
|
||||
int lim = bb.limit();
|
||||
int pos = bb.position();
|
||||
assert (pos <= lim);
|
||||
int rem = (pos <= lim ? lim - pos : 0);
|
||||
|
||||
if (rem > 0) {
|
||||
if (ch != null) {
|
||||
if (ch.write(bb) != rem)
|
||||
assert false : rem;
|
||||
} else {
|
||||
out.write(bb.array(), bb.arrayOffset() + pos, rem);
|
||||
}
|
||||
}
|
||||
bb.clear();
|
||||
}
|
||||
|
||||
private void flushLeftoverChar(CharBuffer cb, boolean endOfInput)
|
||||
throws IOException
|
||||
{
|
||||
if (!haveLeftoverChar && !endOfInput)
|
||||
return;
|
||||
if (lcb == null)
|
||||
lcb = CharBuffer.allocate(2);
|
||||
else
|
||||
lcb.clear();
|
||||
if (haveLeftoverChar)
|
||||
lcb.put(leftoverChar);
|
||||
if ((cb != null) && cb.hasRemaining())
|
||||
lcb.put(cb.get());
|
||||
lcb.flip();
|
||||
while (lcb.hasRemaining() || endOfInput) {
|
||||
CoderResult cr = encoder.encode(lcb, bb, endOfInput);
|
||||
if (cr.isUnderflow()) {
|
||||
if (lcb.hasRemaining()) {
|
||||
leftoverChar = lcb.get();
|
||||
if (cb != null && cb.hasRemaining())
|
||||
flushLeftoverChar(cb, endOfInput);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (cr.isOverflow()) {
|
||||
assert bb.position() > 0;
|
||||
writeBytes();
|
||||
continue;
|
||||
}
|
||||
cr.throwException();
|
||||
}
|
||||
haveLeftoverChar = false;
|
||||
}
|
||||
|
||||
void implWrite(char cbuf[], int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
CharBuffer cb = CharBuffer.wrap(cbuf, off, len);
|
||||
|
||||
if (haveLeftoverChar)
|
||||
flushLeftoverChar(cb, false);
|
||||
|
||||
while (cb.hasRemaining()) {
|
||||
CoderResult cr = encoder.encode(cb, bb, false);
|
||||
if (cr.isUnderflow()) {
|
||||
assert (cb.remaining() <= 1) : cb.remaining();
|
||||
if (cb.remaining() == 1) {
|
||||
haveLeftoverChar = true;
|
||||
leftoverChar = cb.get();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (cr.isOverflow()) {
|
||||
assert bb.position() > 0;
|
||||
writeBytes();
|
||||
continue;
|
||||
}
|
||||
cr.throwException();
|
||||
}
|
||||
}
|
||||
|
||||
void implFlushBuffer() throws IOException {
|
||||
if (bb.position() > 0)
|
||||
writeBytes();
|
||||
}
|
||||
|
||||
void implFlush() throws IOException {
|
||||
implFlushBuffer();
|
||||
if (out != null)
|
||||
out.flush();
|
||||
}
|
||||
|
||||
void implClose() throws IOException {
|
||||
flushLeftoverChar(null, true);
|
||||
try {
|
||||
for (;;) {
|
||||
CoderResult cr = encoder.flush(bb);
|
||||
if (cr.isUnderflow())
|
||||
break;
|
||||
if (cr.isOverflow()) {
|
||||
assert bb.position() > 0;
|
||||
writeBytes();
|
||||
continue;
|
||||
}
|
||||
cr.throwException();
|
||||
}
|
||||
|
||||
if (bb.position() > 0)
|
||||
writeBytes();
|
||||
if (ch != null)
|
||||
ch.close();
|
||||
else
|
||||
out.close();
|
||||
} catch (IOException x) {
|
||||
encoder.reset();
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
String encodingName() {
|
||||
return ((cs instanceof HistoricallyNamedCharset)
|
||||
? ((HistoricallyNamedCharset)cs).historicalName()
|
||||
: cs.name());
|
||||
}
|
||||
}
|
||||
362
jdkSrc/jdk8/sun/nio/cs/Surrogate.java
Normal file
362
jdkSrc/jdk8/sun/nio/cs/Surrogate.java
Normal file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.MalformedInputException;
|
||||
import java.nio.charset.UnmappableCharacterException;
|
||||
|
||||
/**
|
||||
* Utility class for dealing with surrogates.
|
||||
*
|
||||
* @author Mark Reinhold
|
||||
* @author Martin Buchholz
|
||||
* @author Ulf Zibis
|
||||
*/
|
||||
public class Surrogate {
|
||||
|
||||
private Surrogate() { }
|
||||
|
||||
// TODO: Deprecate/remove the following redundant definitions
|
||||
public static final char MIN_HIGH = Character.MIN_HIGH_SURROGATE;
|
||||
public static final char MAX_HIGH = Character.MAX_HIGH_SURROGATE;
|
||||
public static final char MIN_LOW = Character.MIN_LOW_SURROGATE;
|
||||
public static final char MAX_LOW = Character.MAX_LOW_SURROGATE;
|
||||
public static final char MIN = Character.MIN_SURROGATE;
|
||||
public static final char MAX = Character.MAX_SURROGATE;
|
||||
public static final int UCS4_MIN = Character.MIN_SUPPLEMENTARY_CODE_POINT;
|
||||
public static final int UCS4_MAX = Character.MAX_CODE_POINT;
|
||||
|
||||
/**
|
||||
* Tells whether or not the given value is in the high surrogate range.
|
||||
* Use of {@link Character#isHighSurrogate} is generally preferred.
|
||||
*/
|
||||
public static boolean isHigh(int c) {
|
||||
return (MIN_HIGH <= c) && (c <= MAX_HIGH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not the given value is in the low surrogate range.
|
||||
* Use of {@link Character#isLowSurrogate} is generally preferred.
|
||||
*/
|
||||
public static boolean isLow(int c) {
|
||||
return (MIN_LOW <= c) && (c <= MAX_LOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not the given value is in the surrogate range.
|
||||
* Use of {@link Character#isSurrogate} is generally preferred.
|
||||
*/
|
||||
public static boolean is(int c) {
|
||||
return (MIN <= c) && (c <= MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not the given UCS-4 character must be represented as a
|
||||
* surrogate pair in UTF-16.
|
||||
* Use of {@link Character#isSupplementaryCodePoint} is generally preferred.
|
||||
*/
|
||||
public static boolean neededFor(int uc) {
|
||||
return Character.isSupplementaryCodePoint(uc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the high UTF-16 surrogate for the given supplementary UCS-4 character.
|
||||
* Use of {@link Character#highSurrogate} is generally preferred.
|
||||
*/
|
||||
public static char high(int uc) {
|
||||
assert Character.isSupplementaryCodePoint(uc);
|
||||
return Character.highSurrogate(uc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the low UTF-16 surrogate for the given supplementary UCS-4 character.
|
||||
* Use of {@link Character#lowSurrogate} is generally preferred.
|
||||
*/
|
||||
public static char low(int uc) {
|
||||
assert Character.isSupplementaryCodePoint(uc);
|
||||
return Character.lowSurrogate(uc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given surrogate pair into a 32-bit UCS-4 character.
|
||||
* Use of {@link Character#toCodePoint} is generally preferred.
|
||||
*/
|
||||
public static int toUCS4(char c, char d) {
|
||||
assert Character.isHighSurrogate(c) && Character.isLowSurrogate(d);
|
||||
return Character.toCodePoint(c, d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Surrogate parsing support. Charset implementations may use instances of
|
||||
* this class to handle the details of parsing UTF-16 surrogate pairs.
|
||||
*/
|
||||
public static class Parser {
|
||||
|
||||
public Parser() { }
|
||||
|
||||
private int character; // UCS-4
|
||||
private CoderResult error = CoderResult.UNDERFLOW;
|
||||
private boolean isPair;
|
||||
|
||||
/**
|
||||
* Returns the UCS-4 character previously parsed.
|
||||
*/
|
||||
public int character() {
|
||||
assert (error == null);
|
||||
return character;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether or not the previously-parsed UCS-4 character was
|
||||
* originally represented by a surrogate pair.
|
||||
*/
|
||||
public boolean isPair() {
|
||||
assert (error == null);
|
||||
return isPair;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of UTF-16 characters consumed by the previous
|
||||
* parse.
|
||||
*/
|
||||
public int increment() {
|
||||
assert (error == null);
|
||||
return isPair ? 2 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the previous parse operation detected an error, return the object
|
||||
* describing that error.
|
||||
*/
|
||||
public CoderResult error() {
|
||||
assert (error != null);
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmappable-input result object, with the appropriate
|
||||
* input length, for the previously-parsed character.
|
||||
*/
|
||||
public CoderResult unmappableResult() {
|
||||
assert (error == null);
|
||||
return CoderResult.unmappableForLength(isPair ? 2 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a UCS-4 character from the given source buffer, handling
|
||||
* surrogates.
|
||||
*
|
||||
* @param c The first character
|
||||
* @param in The source buffer, from which one more character
|
||||
* will be consumed if c is a high surrogate
|
||||
*
|
||||
* @returns Either a parsed UCS-4 character, in which case the isPair()
|
||||
* and increment() methods will return meaningful values, or
|
||||
* -1, in which case error() will return a descriptive result
|
||||
* object
|
||||
*/
|
||||
public int parse(char c, CharBuffer in) {
|
||||
if (Character.isHighSurrogate(c)) {
|
||||
if (!in.hasRemaining()) {
|
||||
error = CoderResult.UNDERFLOW;
|
||||
return -1;
|
||||
}
|
||||
char d = in.get();
|
||||
if (Character.isLowSurrogate(d)) {
|
||||
character = Character.toCodePoint(c, d);
|
||||
isPair = true;
|
||||
error = null;
|
||||
return character;
|
||||
}
|
||||
error = CoderResult.malformedForLength(1);
|
||||
return -1;
|
||||
}
|
||||
if (Character.isLowSurrogate(c)) {
|
||||
error = CoderResult.malformedForLength(1);
|
||||
return -1;
|
||||
}
|
||||
character = c;
|
||||
isPair = false;
|
||||
error = null;
|
||||
return character;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a UCS-4 character from the given source buffer, handling
|
||||
* surrogates.
|
||||
*
|
||||
* @param c The first character
|
||||
* @param ia The input array, from which one more character
|
||||
* will be consumed if c is a high surrogate
|
||||
* @param ip The input index
|
||||
* @param il The input limit
|
||||
*
|
||||
* @returns Either a parsed UCS-4 character, in which case the isPair()
|
||||
* and increment() methods will return meaningful values, or
|
||||
* -1, in which case error() will return a descriptive result
|
||||
* object
|
||||
*/
|
||||
public int parse(char c, char[] ia, int ip, int il) {
|
||||
assert (ia[ip] == c);
|
||||
if (Character.isHighSurrogate(c)) {
|
||||
if (il - ip < 2) {
|
||||
error = CoderResult.UNDERFLOW;
|
||||
return -1;
|
||||
}
|
||||
char d = ia[ip + 1];
|
||||
if (Character.isLowSurrogate(d)) {
|
||||
character = Character.toCodePoint(c, d);
|
||||
isPair = true;
|
||||
error = null;
|
||||
return character;
|
||||
}
|
||||
error = CoderResult.malformedForLength(1);
|
||||
return -1;
|
||||
}
|
||||
if (Character.isLowSurrogate(c)) {
|
||||
error = CoderResult.malformedForLength(1);
|
||||
return -1;
|
||||
}
|
||||
character = c;
|
||||
isPair = false;
|
||||
error = null;
|
||||
return character;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Surrogate generation support. Charset implementations may use instances
|
||||
* of this class to handle the details of generating UTF-16 surrogate
|
||||
* pairs.
|
||||
*/
|
||||
public static class Generator {
|
||||
|
||||
public Generator() { }
|
||||
|
||||
private CoderResult error = CoderResult.OVERFLOW;
|
||||
|
||||
/**
|
||||
* If the previous generation operation detected an error, return the
|
||||
* object describing that error.
|
||||
*/
|
||||
public CoderResult error() {
|
||||
assert error != null;
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates one or two UTF-16 characters to represent the given UCS-4
|
||||
* character.
|
||||
*
|
||||
* @param uc The UCS-4 character
|
||||
* @param len The number of input bytes from which the UCS-4 value
|
||||
* was constructed (used when creating result objects)
|
||||
* @param dst The destination buffer, to which one or two UTF-16
|
||||
* characters will be written
|
||||
*
|
||||
* @returns Either a positive count of the number of UTF-16 characters
|
||||
* written to the destination buffer, or -1, in which case
|
||||
* error() will return a descriptive result object
|
||||
*/
|
||||
public int generate(int uc, int len, CharBuffer dst) {
|
||||
if (Character.isBmpCodePoint(uc)) {
|
||||
char c = (char) uc;
|
||||
if (Character.isSurrogate(c)) {
|
||||
error = CoderResult.malformedForLength(len);
|
||||
return -1;
|
||||
}
|
||||
if (dst.remaining() < 1) {
|
||||
error = CoderResult.OVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
dst.put(c);
|
||||
error = null;
|
||||
return 1;
|
||||
} else if (Character.isValidCodePoint(uc)) {
|
||||
if (dst.remaining() < 2) {
|
||||
error = CoderResult.OVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
dst.put(Character.highSurrogate(uc));
|
||||
dst.put(Character.lowSurrogate(uc));
|
||||
error = null;
|
||||
return 2;
|
||||
} else {
|
||||
error = CoderResult.unmappableForLength(len);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates one or two UTF-16 characters to represent the given UCS-4
|
||||
* character.
|
||||
*
|
||||
* @param uc The UCS-4 character
|
||||
* @param len The number of input bytes from which the UCS-4 value
|
||||
* was constructed (used when creating result objects)
|
||||
* @param da The destination array, to which one or two UTF-16
|
||||
* characters will be written
|
||||
* @param dp The destination position
|
||||
* @param dl The destination limit
|
||||
*
|
||||
* @returns Either a positive count of the number of UTF-16 characters
|
||||
* written to the destination buffer, or -1, in which case
|
||||
* error() will return a descriptive result object
|
||||
*/
|
||||
public int generate(int uc, int len, char[] da, int dp, int dl) {
|
||||
if (Character.isBmpCodePoint(uc)) {
|
||||
char c = (char) uc;
|
||||
if (Character.isSurrogate(c)) {
|
||||
error = CoderResult.malformedForLength(len);
|
||||
return -1;
|
||||
}
|
||||
if (dl - dp < 1) {
|
||||
error = CoderResult.OVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
da[dp] = c;
|
||||
error = null;
|
||||
return 1;
|
||||
} else if (Character.isValidCodePoint(uc)) {
|
||||
if (dl - dp < 2) {
|
||||
error = CoderResult.OVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
da[dp] = Character.highSurrogate(uc);
|
||||
da[dp + 1] = Character.lowSurrogate(uc);
|
||||
error = null;
|
||||
return 2;
|
||||
} else {
|
||||
error = CoderResult.unmappableForLength(len);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
136
jdkSrc/jdk8/sun/nio/cs/ThreadLocalCoders.java
Normal file
136
jdkSrc/jdk8/sun/nio/cs/ThreadLocalCoders.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.*;
|
||||
|
||||
|
||||
/**
|
||||
* Utility class for caching per-thread decoders and encoders.
|
||||
*/
|
||||
|
||||
public class ThreadLocalCoders {
|
||||
|
||||
private static final int CACHE_SIZE = 3;
|
||||
|
||||
private static abstract class Cache {
|
||||
|
||||
// Thread-local reference to array of cached objects, in LRU order
|
||||
private ThreadLocal<Object[]> cache = new ThreadLocal<>();
|
||||
private final int size;
|
||||
|
||||
Cache(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
abstract Object create(Object name);
|
||||
|
||||
private void moveToFront(Object[] oa, int i) {
|
||||
Object ob = oa[i];
|
||||
for (int j = i; j > 0; j--)
|
||||
oa[j] = oa[j - 1];
|
||||
oa[0] = ob;
|
||||
}
|
||||
|
||||
abstract boolean hasName(Object ob, Object name);
|
||||
|
||||
Object forName(Object name) {
|
||||
Object[] oa = cache.get();
|
||||
if (oa == null) {
|
||||
oa = new Object[size];
|
||||
cache.set(oa);
|
||||
} else {
|
||||
for (int i = 0; i < oa.length; i++) {
|
||||
Object ob = oa[i];
|
||||
if (ob == null)
|
||||
continue;
|
||||
if (hasName(ob, name)) {
|
||||
if (i > 0)
|
||||
moveToFront(oa, i);
|
||||
return ob;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new object
|
||||
Object ob = create(name);
|
||||
oa[oa.length - 1] = ob;
|
||||
moveToFront(oa, oa.length - 1);
|
||||
return ob;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Cache decoderCache = new Cache(CACHE_SIZE) {
|
||||
boolean hasName(Object ob, Object name) {
|
||||
if (name instanceof String)
|
||||
return (((CharsetDecoder)ob).charset().name().equals(name));
|
||||
if (name instanceof Charset)
|
||||
return ((CharsetDecoder)ob).charset().equals(name);
|
||||
return false;
|
||||
}
|
||||
Object create(Object name) {
|
||||
if (name instanceof String)
|
||||
return Charset.forName((String)name).newDecoder();
|
||||
if (name instanceof Charset)
|
||||
return ((Charset)name).newDecoder();
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
public static CharsetDecoder decoderFor(Object name) {
|
||||
CharsetDecoder cd = (CharsetDecoder)decoderCache.forName(name);
|
||||
cd.reset();
|
||||
return cd;
|
||||
}
|
||||
|
||||
private static Cache encoderCache = new Cache(CACHE_SIZE) {
|
||||
boolean hasName(Object ob, Object name) {
|
||||
if (name instanceof String)
|
||||
return (((CharsetEncoder)ob).charset().name().equals(name));
|
||||
if (name instanceof Charset)
|
||||
return ((CharsetEncoder)ob).charset().equals(name);
|
||||
return false;
|
||||
}
|
||||
Object create(Object name) {
|
||||
if (name instanceof String)
|
||||
return Charset.forName((String)name).newEncoder();
|
||||
if (name instanceof Charset)
|
||||
return ((Charset)name).newEncoder();
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
public static CharsetEncoder encoderFor(Object name) {
|
||||
CharsetEncoder ce = (CharsetEncoder)encoderCache.forName(name);
|
||||
ce.reset();
|
||||
return ce;
|
||||
}
|
||||
|
||||
}
|
||||
264
jdkSrc/jdk8/sun/nio/cs/US_ASCII.java
Normal file
264
jdkSrc/jdk8/sun/nio/cs/US_ASCII.java
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class US_ASCII
|
||||
extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
|
||||
public US_ASCII() {
|
||||
super("US-ASCII", StandardCharsets.aliases_US_ASCII);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "ASCII";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof US_ASCII);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends CharsetDecoder
|
||||
implements ArrayDecoder {
|
||||
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
assert (sp <= sl);
|
||||
sp = (sp <= sl ? sp : sl);
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
byte b = sa[sp];
|
||||
if (b >= 0) {
|
||||
if (dp >= dl)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (char)b;
|
||||
sp++;
|
||||
continue;
|
||||
}
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
byte b = src.get();
|
||||
if (b >= 0) {
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((char)b);
|
||||
mark++;
|
||||
continue;
|
||||
}
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private char repl = '\uFFFD';
|
||||
protected void implReplaceWith(String newReplacement) {
|
||||
repl = newReplacement.charAt(0);
|
||||
}
|
||||
|
||||
public int decode(byte[] src, int sp, int len, char[] dst) {
|
||||
int dp = 0;
|
||||
len = Math.min(len, dst.length);
|
||||
while (dp < len) {
|
||||
byte b = src[sp++];
|
||||
if (b >= 0)
|
||||
dst[dp++] = (char)b;
|
||||
else
|
||||
dst[dp++] = repl;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder {
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return c < 0x80;
|
||||
}
|
||||
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return (repl.length == 1 && repl[0] >= 0) ||
|
||||
super.isLegalReplacement(repl);
|
||||
}
|
||||
|
||||
private final Surrogate.Parser sgp = new Surrogate.Parser();
|
||||
private CoderResult encodeArrayLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
assert (sp <= sl);
|
||||
sp = (sp <= sl ? sp : sl);
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
if (c < 0x80) {
|
||||
if (dp >= dl)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp] = (byte)c;
|
||||
sp++; dp++;
|
||||
continue;
|
||||
}
|
||||
if (sgp.parse(c, sa, sp, sl) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (c < 0x80) {
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)c);
|
||||
mark++;
|
||||
continue;
|
||||
}
|
||||
if (sgp.parse(c, src) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private byte repl = (byte)'?';
|
||||
protected void implReplaceWith(byte[] newReplacement) {
|
||||
repl = newReplacement[0];
|
||||
}
|
||||
|
||||
public int encode(char[] src, int sp, int len, byte[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + Math.min(len, dst.length);
|
||||
while (sp < sl) {
|
||||
char c = src[sp++];
|
||||
if (c < 0x80) {
|
||||
dst[dp++] = (byte)c;
|
||||
continue;
|
||||
}
|
||||
if (Character.isHighSurrogate(c) && sp < sl &&
|
||||
Character.isLowSurrogate(src[sp])) {
|
||||
if (len > dst.length) {
|
||||
sl++;
|
||||
len--;
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
dst[dp++] = repl;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
65
jdkSrc/jdk8/sun/nio/cs/UTF_16.java
Normal file
65
jdkSrc/jdk8/sun/nio/cs/UTF_16.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
class UTF_16 extends Unicode
|
||||
{
|
||||
|
||||
public UTF_16() {
|
||||
super("UTF-16", StandardCharsets.aliases_UTF_16);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UTF-16";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends UnicodeDecoder {
|
||||
|
||||
public Decoder(Charset cs) {
|
||||
super(cs, NONE);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends UnicodeEncoder {
|
||||
|
||||
public Encoder(Charset cs) {
|
||||
super(cs, BIG, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
65
jdkSrc/jdk8/sun/nio/cs/UTF_16BE.java
Normal file
65
jdkSrc/jdk8/sun/nio/cs/UTF_16BE.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
class UTF_16BE extends Unicode
|
||||
{
|
||||
|
||||
public UTF_16BE() {
|
||||
super("UTF-16BE", StandardCharsets.aliases_UTF_16BE);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UnicodeBigUnmarked";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends UnicodeDecoder {
|
||||
|
||||
public Decoder(Charset cs) {
|
||||
super(cs, BIG);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends UnicodeEncoder {
|
||||
|
||||
public Encoder(Charset cs) {
|
||||
super(cs, BIG, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
65
jdkSrc/jdk8/sun/nio/cs/UTF_16LE.java
Normal file
65
jdkSrc/jdk8/sun/nio/cs/UTF_16LE.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
class UTF_16LE extends Unicode
|
||||
{
|
||||
|
||||
public UTF_16LE() {
|
||||
super("UTF-16LE", StandardCharsets.aliases_UTF_16LE);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UnicodeLittleUnmarked";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends UnicodeDecoder {
|
||||
|
||||
public Decoder(Charset cs) {
|
||||
super(cs, LITTLE);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends UnicodeEncoder {
|
||||
|
||||
public Encoder(Charset cs) {
|
||||
super(cs, LITTLE, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
65
jdkSrc/jdk8/sun/nio/cs/UTF_16LE_BOM.java
Normal file
65
jdkSrc/jdk8/sun/nio/cs/UTF_16LE_BOM.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
class UTF_16LE_BOM extends Unicode
|
||||
{
|
||||
|
||||
public UTF_16LE_BOM() {
|
||||
super("x-UTF-16LE-BOM", StandardCharsets.aliases_UTF_16LE_BOM);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UnicodeLittle";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends UnicodeDecoder {
|
||||
|
||||
public Decoder(Charset cs) {
|
||||
super(cs, NONE, LITTLE);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends UnicodeEncoder {
|
||||
|
||||
public Encoder(Charset cs) {
|
||||
super(cs, LITTLE, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
48
jdkSrc/jdk8/sun/nio/cs/UTF_32.java
Normal file
48
jdkSrc/jdk8/sun/nio/cs/UTF_32.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
public class UTF_32 extends Unicode
|
||||
{
|
||||
public UTF_32() {
|
||||
super("UTF-32", StandardCharsets.aliases_UTF_32);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UTF-32";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new UTF_32Coder.Decoder(this, UTF_32Coder.NONE);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new UTF_32Coder.Encoder(this, UTF_32Coder.BIG, false);
|
||||
}
|
||||
}
|
||||
48
jdkSrc/jdk8/sun/nio/cs/UTF_32BE.java
Normal file
48
jdkSrc/jdk8/sun/nio/cs/UTF_32BE.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
public class UTF_32BE extends Unicode
|
||||
{
|
||||
public UTF_32BE() {
|
||||
super("UTF-32BE", StandardCharsets.aliases_UTF_32BE);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UTF-32BE";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new UTF_32Coder.Decoder(this, UTF_32Coder.BIG);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new UTF_32Coder.Encoder(this, UTF_32Coder.BIG, false);
|
||||
}
|
||||
}
|
||||
48
jdkSrc/jdk8/sun/nio/cs/UTF_32BE_BOM.java
Normal file
48
jdkSrc/jdk8/sun/nio/cs/UTF_32BE_BOM.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
public class UTF_32BE_BOM extends Unicode
|
||||
{
|
||||
public UTF_32BE_BOM() {
|
||||
super("X-UTF-32BE-BOM", StandardCharsets.aliases_UTF_32BE_BOM);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "X-UTF-32BE-BOM";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new UTF_32Coder.Decoder(this, UTF_32Coder.BIG);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new UTF_32Coder.Encoder(this, UTF_32Coder.BIG, true);
|
||||
}
|
||||
}
|
||||
189
jdkSrc/jdk8/sun/nio/cs/UTF_32Coder.java
Normal file
189
jdkSrc/jdk8/sun/nio/cs/UTF_32Coder.java
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
class UTF_32Coder {
|
||||
protected static final int BOM_BIG = 0xFEFF;
|
||||
protected static final int BOM_LITTLE = 0xFFFE0000;
|
||||
protected static final int NONE = 0;
|
||||
protected static final int BIG = 1;
|
||||
protected static final int LITTLE = 2;
|
||||
|
||||
protected static class Decoder extends CharsetDecoder {
|
||||
private int currentBO;
|
||||
private int expectedBO;
|
||||
|
||||
protected Decoder(Charset cs, int bo) {
|
||||
super(cs, 0.25f, 1.0f);
|
||||
this.expectedBO = bo;
|
||||
this.currentBO = NONE;
|
||||
}
|
||||
|
||||
private int getCP(ByteBuffer src) {
|
||||
return (currentBO==BIG)
|
||||
?(((src.get() & 0xff) << 24) |
|
||||
((src.get() & 0xff) << 16) |
|
||||
((src.get() & 0xff) << 8) |
|
||||
(src.get() & 0xff))
|
||||
:((src.get() & 0xff) |
|
||||
((src.get() & 0xff) << 8) |
|
||||
((src.get() & 0xff) << 16) |
|
||||
((src.get() & 0xff) << 24));
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
|
||||
if (src.remaining() < 4)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int mark = src.position();
|
||||
int cp;
|
||||
try {
|
||||
if (currentBO == NONE) {
|
||||
cp = ((src.get() & 0xff) << 24) |
|
||||
((src.get() & 0xff) << 16) |
|
||||
((src.get() & 0xff) << 8) |
|
||||
(src.get() & 0xff);
|
||||
if (cp == BOM_BIG && expectedBO != LITTLE) {
|
||||
currentBO = BIG;
|
||||
mark += 4;
|
||||
} else if (cp == BOM_LITTLE && expectedBO != BIG) {
|
||||
currentBO = LITTLE;
|
||||
mark += 4;
|
||||
} else {
|
||||
if (expectedBO == NONE)
|
||||
currentBO = BIG;
|
||||
else
|
||||
currentBO = expectedBO;
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
while (src.remaining() >= 4) {
|
||||
cp = getCP(src);
|
||||
if (Character.isBmpCodePoint(cp)) {
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
mark += 4;
|
||||
dst.put((char) cp);
|
||||
} else if (Character.isValidCodePoint(cp)) {
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark += 4;
|
||||
dst.put(Character.highSurrogate(cp));
|
||||
dst.put(Character.lowSurrogate(cp));
|
||||
} else {
|
||||
return CoderResult.malformedForLength(4);
|
||||
}
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
protected void implReset() {
|
||||
currentBO = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class Encoder extends CharsetEncoder {
|
||||
private boolean doBOM = false;
|
||||
private boolean doneBOM = true;
|
||||
private int byteOrder;
|
||||
|
||||
protected void put(int cp, ByteBuffer dst) {
|
||||
if (byteOrder==BIG) {
|
||||
dst.put((byte)(cp >> 24));
|
||||
dst.put((byte)(cp >> 16));
|
||||
dst.put((byte)(cp >> 8));
|
||||
dst.put((byte)cp);
|
||||
} else {
|
||||
dst.put((byte)cp);
|
||||
dst.put((byte)(cp >> 8));
|
||||
dst.put((byte)(cp >> 16));
|
||||
dst.put((byte)(cp >> 24));
|
||||
}
|
||||
}
|
||||
|
||||
protected Encoder(Charset cs, int byteOrder, boolean doBOM) {
|
||||
super(cs, 4.0f,
|
||||
doBOM?8.0f:4.0f,
|
||||
(byteOrder==BIG)?new byte[]{(byte)0, (byte)0, (byte)0xff, (byte)0xfd}
|
||||
:new byte[]{(byte)0xfd, (byte)0xff, (byte)0, (byte)0});
|
||||
this.byteOrder = byteOrder;
|
||||
this.doBOM = doBOM;
|
||||
this.doneBOM = !doBOM;
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
|
||||
int mark = src.position();
|
||||
if (!doneBOM && src.hasRemaining()) {
|
||||
if (dst.remaining() < 4)
|
||||
return CoderResult.OVERFLOW;
|
||||
put(BOM_BIG, dst);
|
||||
doneBOM = true;
|
||||
}
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (!Character.isSurrogate(c)) {
|
||||
if (dst.remaining() < 4)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark++;
|
||||
put(c, dst);
|
||||
} else if (Character.isHighSurrogate(c)) {
|
||||
if (!src.hasRemaining())
|
||||
return CoderResult.UNDERFLOW;
|
||||
char low = src.get();
|
||||
if (Character.isLowSurrogate(low)) {
|
||||
if (dst.remaining() < 4)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark += 2;
|
||||
put(Character.toCodePoint(c, low), dst);
|
||||
} else {
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
} else {
|
||||
// assert Character.isLowSurrogate(c);
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected void implReset() {
|
||||
doneBOM = !doBOM;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
49
jdkSrc/jdk8/sun/nio/cs/UTF_32LE.java
Normal file
49
jdkSrc/jdk8/sun/nio/cs/UTF_32LE.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
public class UTF_32LE extends Unicode
|
||||
{
|
||||
public UTF_32LE() {
|
||||
super("UTF-32LE", StandardCharsets.aliases_UTF_32LE);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UTF-32LE";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new UTF_32Coder.Decoder(this, UTF_32Coder.LITTLE);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new UTF_32Coder.Encoder(this, UTF_32Coder.LITTLE, false);
|
||||
}
|
||||
}
|
||||
48
jdkSrc/jdk8/sun/nio/cs/UTF_32LE_BOM.java
Normal file
48
jdkSrc/jdk8/sun/nio/cs/UTF_32LE_BOM.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
|
||||
public class UTF_32LE_BOM extends Unicode
|
||||
{
|
||||
public UTF_32LE_BOM() {
|
||||
super("X-UTF-32LE-BOM", StandardCharsets.aliases_UTF_32LE_BOM);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "X-UTF-32LE-BOM";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new UTF_32Coder.Decoder(this, UTF_32Coder.LITTLE);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new UTF_32Coder.Encoder(this, UTF_32Coder.LITTLE, true);
|
||||
}
|
||||
}
|
||||
746
jdkSrc/jdk8/sun/nio/cs/UTF_8.java
Normal file
746
jdkSrc/jdk8/sun/nio/cs/UTF_8.java
Normal file
@@ -0,0 +1,746 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
/* Legal UTF-8 Byte Sequences
|
||||
*
|
||||
* # Code Points Bits Bit/Byte pattern
|
||||
* 1 7 0xxxxxxx
|
||||
* U+0000..U+007F 00..7F
|
||||
*
|
||||
* 2 11 110xxxxx 10xxxxxx
|
||||
* U+0080..U+07FF C2..DF 80..BF
|
||||
*
|
||||
* 3 16 1110xxxx 10xxxxxx 10xxxxxx
|
||||
* U+0800..U+0FFF E0 A0..BF 80..BF
|
||||
* U+1000..U+FFFF E1..EF 80..BF 80..BF
|
||||
*
|
||||
* 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
* U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
|
||||
* U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
|
||||
* U+100000..U10FFFF F4 80..8F 80..BF 80..BF
|
||||
*
|
||||
*/
|
||||
|
||||
class UTF_8 extends Unicode
|
||||
{
|
||||
public UTF_8() {
|
||||
super("UTF-8", StandardCharsets.aliases_UTF_8);
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "UTF8";
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static final void updatePositions(Buffer src, int sp,
|
||||
Buffer dst, int dp) {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
|
||||
private static class Decoder extends CharsetDecoder
|
||||
implements ArrayDecoder {
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
private static boolean isNotContinuation(int b) {
|
||||
return (b & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// [E0] [A0..BF] [80..BF]
|
||||
// [E1..EF] [80..BF] [80..BF]
|
||||
private static boolean isMalformed3(int b1, int b2, int b3) {
|
||||
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
(b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is only one byte left in src buffer
|
||||
private static boolean isMalformed3_2(int b1, int b2) {
|
||||
return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// [F0] [90..BF] [80..BF] [80..BF]
|
||||
// [F1..F3] [80..BF] [80..BF] [80..BF]
|
||||
// [F4] [80..8F] [80..BF] [80..BF]
|
||||
// only check 80-be range here, the [0xf0,0x80...] and [0xf4,0x90-...]
|
||||
// will be checked by Character.isSupplementaryCodePoint(uc)
|
||||
private static boolean isMalformed4(int b2, int b3, int b4) {
|
||||
return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 ||
|
||||
(b4 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// only used when there is less than 4 bytes left in src buffer.
|
||||
// both b1 and b2 should be "& 0xff" before passed in.
|
||||
private static boolean isMalformed4_2(int b1, int b2) {
|
||||
return (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
|
||||
(b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
|
||||
(b2 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
// tests if b1 and b2 are malformed as the first 2 bytes of a
|
||||
// legal`4-byte utf-8 byte sequence.
|
||||
// only used when there is less than 4 bytes left in src buffer,
|
||||
// after isMalformed4_2 has been invoked.
|
||||
private static boolean isMalformed4_3(int b3) {
|
||||
return (b3 & 0xc0) != 0x80;
|
||||
}
|
||||
|
||||
private static CoderResult lookupN(ByteBuffer src, int n)
|
||||
{
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (isNotContinuation(src.get()))
|
||||
return CoderResult.malformedForLength(i);
|
||||
}
|
||||
return CoderResult.malformedForLength(n);
|
||||
}
|
||||
|
||||
private static CoderResult malformedN(ByteBuffer src, int nb) {
|
||||
switch (nb) {
|
||||
case 1:
|
||||
case 2: // always 1
|
||||
return CoderResult.malformedForLength(1);
|
||||
case 3:
|
||||
int b1 = src.get();
|
||||
int b2 = src.get(); // no need to lookup b3
|
||||
return CoderResult.malformedForLength(
|
||||
((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) ||
|
||||
isNotContinuation(b2)) ? 1 : 2);
|
||||
case 4: // we don't care the speed here
|
||||
b1 = src.get() & 0xff;
|
||||
b2 = src.get() & 0xff;
|
||||
if (b1 > 0xf4 ||
|
||||
(b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) ||
|
||||
(b1 == 0xf4 && (b2 & 0xf0) != 0x80) ||
|
||||
isNotContinuation(b2))
|
||||
return CoderResult.malformedForLength(1);
|
||||
if (isNotContinuation(src.get()))
|
||||
return CoderResult.malformedForLength(2);
|
||||
return CoderResult.malformedForLength(3);
|
||||
default:
|
||||
assert false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static CoderResult malformed(ByteBuffer src, int sp,
|
||||
CharBuffer dst, int dp,
|
||||
int nb)
|
||||
{
|
||||
src.position(sp - src.arrayOffset());
|
||||
CoderResult cr = malformedN(src, nb);
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return cr;
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult malformed(ByteBuffer src,
|
||||
int mark, int nb)
|
||||
{
|
||||
src.position(mark);
|
||||
CoderResult cr = malformedN(src, nb);
|
||||
src.position(mark);
|
||||
return cr;
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int sp,
|
||||
CharBuffer dst,
|
||||
int dp,
|
||||
int malformedNB)
|
||||
{
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
private static CoderResult malformedForLength(ByteBuffer src,
|
||||
int mark,
|
||||
int malformedNB)
|
||||
{
|
||||
src.position(mark);
|
||||
return CoderResult.malformedForLength(malformedNB);
|
||||
}
|
||||
|
||||
|
||||
private static CoderResult xflow(Buffer src, int sp, int sl,
|
||||
Buffer dst, int dp, int nb) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return (nb == 0 || sl - sp < nb)
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static CoderResult xflow(Buffer src, int mark, int nb) {
|
||||
src.position(mark);
|
||||
return (nb == 0 || src.remaining() < nb)
|
||||
? CoderResult.UNDERFLOW : CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
// This method is optimized for ASCII input.
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
int dlASCII = dp + Math.min(sl - sp, dl - dp);
|
||||
|
||||
// ASCII only loop
|
||||
while (dp < dlASCII && sa[sp] >= 0)
|
||||
da[dp++] = (char) sa[sp++];
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp];
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
if (dp >= dl)
|
||||
return xflow(src, sp, sl, dst, dp, 1);
|
||||
da[dp++] = (char) b1;
|
||||
sp++;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
// [C2..DF] [80..BF]
|
||||
if (sl - sp < 2 || dp >= dl)
|
||||
return xflow(src, sp, sl, dst, dp, 2);
|
||||
int b2 = sa[sp + 1];
|
||||
// Now we check the first byte of 2-byte sequence as
|
||||
// if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0)
|
||||
// no longer need to check b1 against c1 & c0 for
|
||||
// malformed as we did in previous version
|
||||
// (b1 & 0x1e) == 0x0 || (b2 & 0xc0) != 0x80;
|
||||
// only need to check the second byte b2.
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
da[dp++] = (char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0)));
|
||||
sp += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = sl - sp;
|
||||
if (srcRemaining < 3 || dp >= dl) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, sa[sp + 1]))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
return xflow(src, sp, sl, dst, dp, 3);
|
||||
}
|
||||
int b2 = sa[sp + 1];
|
||||
int b3 = sa[sp + 2];
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, sp, dst, dp, 3);
|
||||
char c = (char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (Character.isSurrogate(c))
|
||||
return malformedForLength(src, sp, dst, dp, 3);
|
||||
da[dp++] = c;
|
||||
sp += 3;
|
||||
} else if ((b1 >> 3) == -2) {
|
||||
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = sl - sp;
|
||||
if (srcRemaining < 4 || dl - dp < 2) {
|
||||
b1 &= 0xff;
|
||||
if (b1 > 0xf4 ||
|
||||
srcRemaining > 1 && isMalformed4_2(b1, sa[sp + 1] & 0xff))
|
||||
return malformedForLength(src, sp, dst, dp, 1);
|
||||
if (srcRemaining > 2 && isMalformed4_3(sa[sp + 2]))
|
||||
return malformedForLength(src, sp, dst, dp, 2);
|
||||
return xflow(src, sp, sl, dst, dp, 4);
|
||||
}
|
||||
int b2 = sa[sp + 1];
|
||||
int b3 = sa[sp + 2];
|
||||
int b4 = sa[sp + 3];
|
||||
int uc = ((b1 << 18) ^
|
||||
(b2 << 12) ^
|
||||
(b3 << 6) ^
|
||||
(b4 ^
|
||||
(((byte) 0xF0 << 18) ^
|
||||
((byte) 0x80 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (isMalformed4(b2, b3, b4) ||
|
||||
// shortest form check
|
||||
!Character.isSupplementaryCodePoint(uc)) {
|
||||
return malformed(src, sp, dst, dp, 4);
|
||||
}
|
||||
da[dp++] = Character.highSurrogate(uc);
|
||||
da[dp++] = Character.lowSurrogate(uc);
|
||||
sp += 4;
|
||||
} else
|
||||
return malformed(src, sp, dst, dp, 1);
|
||||
}
|
||||
return xflow(src, sp, sl, dst, dp, 0);
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
int limit = src.limit();
|
||||
while (mark < limit) {
|
||||
int b1 = src.get();
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
if (dst.remaining() < 1)
|
||||
return xflow(src, mark, 1); // overflow
|
||||
dst.put((char) b1);
|
||||
mark++;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (limit - mark < 2|| dst.remaining() < 1)
|
||||
return xflow(src, mark, 2);
|
||||
int b2 = src.get();
|
||||
if (isNotContinuation(b2))
|
||||
return malformedForLength(src, mark, 1);
|
||||
dst.put((char) (((b1 << 6) ^ b2)
|
||||
^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
mark += 2;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = limit - mark;
|
||||
if (srcRemaining < 3 || dst.remaining() < 1) {
|
||||
if (srcRemaining > 1 && isMalformed3_2(b1, src.get()))
|
||||
return malformedForLength(src, mark, 1);
|
||||
return xflow(src, mark, 3);
|
||||
}
|
||||
int b2 = src.get();
|
||||
int b3 = src.get();
|
||||
if (isMalformed3(b1, b2, b3))
|
||||
return malformed(src, mark, 3);
|
||||
char c = (char)
|
||||
((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (Character.isSurrogate(c))
|
||||
return malformedForLength(src, mark, 3);
|
||||
dst.put(c);
|
||||
mark += 3;
|
||||
} else if ((b1 >> 3) == -2) {
|
||||
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
int srcRemaining = limit - mark;
|
||||
if (srcRemaining < 4 || dst.remaining() < 2) {
|
||||
b1 &= 0xff;
|
||||
if (b1 > 0xf4 ||
|
||||
srcRemaining > 1 && isMalformed4_2(b1, src.get() & 0xff))
|
||||
return malformedForLength(src, mark, 1);
|
||||
if (srcRemaining > 2 && isMalformed4_3(src.get()))
|
||||
return malformedForLength(src, mark, 2);
|
||||
return xflow(src, mark, 4);
|
||||
}
|
||||
int b2 = src.get();
|
||||
int b3 = src.get();
|
||||
int b4 = src.get();
|
||||
int uc = ((b1 << 18) ^
|
||||
(b2 << 12) ^
|
||||
(b3 << 6) ^
|
||||
(b4 ^
|
||||
(((byte) 0xF0 << 18) ^
|
||||
((byte) 0x80 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (isMalformed4(b2, b3, b4) ||
|
||||
// shortest form check
|
||||
!Character.isSupplementaryCodePoint(uc)) {
|
||||
return malformed(src, mark, 4);
|
||||
}
|
||||
dst.put(Character.highSurrogate(uc));
|
||||
dst.put(Character.lowSurrogate(uc));
|
||||
mark += 4;
|
||||
} else {
|
||||
return malformed(src, mark, 1);
|
||||
}
|
||||
}
|
||||
return xflow(src, mark, 0);
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private static ByteBuffer getByteBuffer(ByteBuffer bb, byte[] ba, int sp)
|
||||
{
|
||||
if (bb == null)
|
||||
bb = ByteBuffer.wrap(ba);
|
||||
bb.position(sp);
|
||||
return bb;
|
||||
}
|
||||
|
||||
// returns -1 if there is/are malformed byte(s) and the
|
||||
// "action" for malformed input is not REPLACE.
|
||||
public int decode(byte[] sa, int sp, int len, char[] da) {
|
||||
final int sl = sp + len;
|
||||
int dp = 0;
|
||||
int dlASCII = Math.min(len, da.length);
|
||||
ByteBuffer bb = null; // only necessary if malformed
|
||||
|
||||
// ASCII only optimized loop
|
||||
while (dp < dlASCII && sa[sp] >= 0)
|
||||
da[dp++] = (char) sa[sp++];
|
||||
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp++];
|
||||
if (b1 >= 0) {
|
||||
// 1 byte, 7 bits: 0xxxxxxx
|
||||
da[dp++] = (char) b1;
|
||||
} else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) {
|
||||
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
|
||||
if (sp < sl) {
|
||||
int b2 = sa[sp++];
|
||||
if (isNotContinuation(b2)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp--; // malformedN(bb, 2) always returns 1
|
||||
} else {
|
||||
da[dp++] = (char) (((b1 << 6) ^ b2)^
|
||||
(((byte) 0xC0 << 6) ^
|
||||
((byte) 0x80 << 0)));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else if ((b1 >> 4) == -2) {
|
||||
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
|
||||
if (sp + 1 < sl) {
|
||||
int b2 = sa[sp++];
|
||||
int b3 = sa[sp++];
|
||||
if (isMalformed3(b1, b2, b3)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp -= 3;
|
||||
bb = getByteBuffer(bb, sa, sp);
|
||||
sp += malformedN(bb, 3).length();
|
||||
} else {
|
||||
char c = (char)((b1 << 12) ^
|
||||
(b2 << 6) ^
|
||||
(b3 ^
|
||||
(((byte) 0xE0 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
} else {
|
||||
da[dp++] = c;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
if (sp < sl && isMalformed3_2(b1, sa[sp])) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
|
||||
}
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else if ((b1 >> 3) == -2) {
|
||||
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
if (sp + 2 < sl) {
|
||||
int b2 = sa[sp++];
|
||||
int b3 = sa[sp++];
|
||||
int b4 = sa[sp++];
|
||||
int uc = ((b1 << 18) ^
|
||||
(b2 << 12) ^
|
||||
(b3 << 6) ^
|
||||
(b4 ^
|
||||
(((byte) 0xF0 << 18) ^
|
||||
((byte) 0x80 << 12) ^
|
||||
((byte) 0x80 << 6) ^
|
||||
((byte) 0x80 << 0))));
|
||||
if (isMalformed4(b2, b3, b4) ||
|
||||
// shortest form check
|
||||
!Character.isSupplementaryCodePoint(uc)) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
sp -= 4;
|
||||
bb = getByteBuffer(bb, sa, sp);
|
||||
sp += malformedN(bb, 4).length();
|
||||
} else {
|
||||
da[dp++] = Character.highSurrogate(uc);
|
||||
da[dp++] = Character.lowSurrogate(uc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
b1 &= 0xff;
|
||||
if (b1 > 0xf4 ||
|
||||
sp < sl && isMalformed4_2(b1, sa[sp] & 0xff)) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
}
|
||||
sp++;
|
||||
if (sp < sl && isMalformed4_3(sa[sp])) {
|
||||
da[dp++] = replacement().charAt(0);
|
||||
continue;
|
||||
}
|
||||
da[dp++] = replacement().charAt(0);
|
||||
return dp;
|
||||
} else {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = replacement().charAt(0);
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder {
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, 1.1f, 3.0f);
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return !Character.isSurrogate(c);
|
||||
}
|
||||
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return ((repl.length == 1 && repl[0] >= 0) ||
|
||||
super.isLegalReplacement(repl));
|
||||
}
|
||||
|
||||
private static CoderResult overflow(CharBuffer src, int sp,
|
||||
ByteBuffer dst, int dp) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private static CoderResult overflow(CharBuffer src, int mark) {
|
||||
src.position(mark);
|
||||
return CoderResult.OVERFLOW;
|
||||
}
|
||||
|
||||
private Surrogate.Parser sgp;
|
||||
private CoderResult encodeArrayLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
int dlASCII = dp + Math.min(sl - sp, dl - dp);
|
||||
|
||||
// ASCII only loop
|
||||
while (dp < dlASCII && sa[sp] < '\u0080')
|
||||
da[dp++] = (byte) sa[sp++];
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
if (dp >= dl)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)c;
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
if (dl - dp < 2)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)(0xc0 | (c >> 6));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
// Have a surrogate pair
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, sa, sp, sl);
|
||||
if (uc < 0) {
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return sgp.error();
|
||||
}
|
||||
if (dl - dp < 4)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)(0xf0 | ((uc >> 18)));
|
||||
da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f));
|
||||
da[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f));
|
||||
da[dp++] = (byte)(0x80 | (uc & 0x3f));
|
||||
sp++; // 2 chars
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
if (dl - dp < 3)
|
||||
return overflow(src, sp, dst, dp);
|
||||
da[dp++] = (byte)(0xe0 | ((c >> 12)));
|
||||
da[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
updatePositions(src, sp, dst, dp);
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
if (!dst.hasRemaining())
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)c);
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
if (dst.remaining() < 2)
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)(0xc0 | (c >> 6)));
|
||||
dst.put((byte)(0x80 | (c & 0x3f)));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
// Have a surrogate pair
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, src);
|
||||
if (uc < 0) {
|
||||
src.position(mark);
|
||||
return sgp.error();
|
||||
}
|
||||
if (dst.remaining() < 4)
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)(0xf0 | ((uc >> 18))));
|
||||
dst.put((byte)(0x80 | ((uc >> 12) & 0x3f)));
|
||||
dst.put((byte)(0x80 | ((uc >> 6) & 0x3f)));
|
||||
dst.put((byte)(0x80 | (uc & 0x3f)));
|
||||
mark++; // 2 chars
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
if (dst.remaining() < 3)
|
||||
return overflow(src, mark);
|
||||
dst.put((byte)(0xe0 | ((c >> 12))));
|
||||
dst.put((byte)(0x80 | ((c >> 6) & 0x3f)));
|
||||
dst.put((byte)(0x80 | (c & 0x3f)));
|
||||
}
|
||||
mark++;
|
||||
}
|
||||
src.position(mark);
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
protected final CoderResult encodeLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private byte repl = (byte)'?';
|
||||
protected void implReplaceWith(byte[] newReplacement) {
|
||||
repl = newReplacement[0];
|
||||
}
|
||||
|
||||
// returns -1 if there is malformed char(s) and the
|
||||
// "action" for malformed input is not REPLACE.
|
||||
public int encode(char[] sa, int sp, int len, byte[] da) {
|
||||
int sl = sp + len;
|
||||
int dp = 0;
|
||||
int dlASCII = dp + Math.min(len, da.length);
|
||||
|
||||
// ASCII only optimized loop
|
||||
while (dp < dlASCII && sa[sp] < '\u0080')
|
||||
da[dp++] = (byte) sa[sp++];
|
||||
|
||||
while (sp < sl) {
|
||||
char c = sa[sp++];
|
||||
if (c < 0x80) {
|
||||
// Have at most seven bits
|
||||
da[dp++] = (byte)c;
|
||||
} else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
da[dp++] = (byte)(0xc0 | (c >> 6));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
} else if (Character.isSurrogate(c)) {
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
int uc = sgp.parse(c, sa, sp - 1, sl);
|
||||
if (uc < 0) {
|
||||
if (malformedInputAction() != CodingErrorAction.REPLACE)
|
||||
return -1;
|
||||
da[dp++] = repl;
|
||||
} else {
|
||||
da[dp++] = (byte)(0xf0 | ((uc >> 18)));
|
||||
da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f));
|
||||
da[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f));
|
||||
da[dp++] = (byte)(0x80 | (uc & 0x3f));
|
||||
sp++; // 2 chars
|
||||
}
|
||||
} else {
|
||||
// 3 bytes, 16 bits
|
||||
da[dp++] = (byte)(0xe0 | ((c >> 12)));
|
||||
da[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f));
|
||||
da[dp++] = (byte)(0x80 | (c & 0x3f));
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
}
|
||||
92
jdkSrc/jdk8/sun/nio/cs/Unicode.java
Normal file
92
jdkSrc/jdk8/sun/nio/cs/Unicode.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
abstract class Unicode extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
public Unicode(String name, String[] aliases) {
|
||||
super(name, aliases);
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs instanceof US_ASCII)
|
||||
|| (cs instanceof ISO_8859_1)
|
||||
|| (cs instanceof ISO_8859_15)
|
||||
|| (cs instanceof MS1252)
|
||||
|| (cs instanceof UTF_8)
|
||||
|| (cs instanceof UTF_16)
|
||||
|| (cs instanceof UTF_16BE)
|
||||
|| (cs instanceof UTF_16LE)
|
||||
|| (cs instanceof UTF_16LE_BOM)
|
||||
|| (cs.name().equals("GBK"))
|
||||
|| (cs.name().equals("GB18030"))
|
||||
|| (cs.name().equals("ISO-8859-2"))
|
||||
|| (cs.name().equals("ISO-8859-3"))
|
||||
|| (cs.name().equals("ISO-8859-4"))
|
||||
|| (cs.name().equals("ISO-8859-5"))
|
||||
|| (cs.name().equals("ISO-8859-6"))
|
||||
|| (cs.name().equals("ISO-8859-7"))
|
||||
|| (cs.name().equals("ISO-8859-8"))
|
||||
|| (cs.name().equals("ISO-8859-9"))
|
||||
|| (cs.name().equals("ISO-8859-13"))
|
||||
|| (cs.name().equals("JIS_X0201"))
|
||||
|| (cs.name().equals("x-JIS0208"))
|
||||
|| (cs.name().equals("JIS_X0212-1990"))
|
||||
|| (cs.name().equals("GB2312"))
|
||||
|| (cs.name().equals("EUC-KR"))
|
||||
|| (cs.name().equals("x-EUC-TW"))
|
||||
|| (cs.name().equals("EUC-JP"))
|
||||
|| (cs.name().equals("x-euc-jp-linux"))
|
||||
|| (cs.name().equals("KOI8-R"))
|
||||
|| (cs.name().equals("TIS-620"))
|
||||
|| (cs.name().equals("x-ISCII91"))
|
||||
|| (cs.name().equals("windows-1251"))
|
||||
|| (cs.name().equals("windows-1253"))
|
||||
|| (cs.name().equals("windows-1254"))
|
||||
|| (cs.name().equals("windows-1255"))
|
||||
|| (cs.name().equals("windows-1256"))
|
||||
|| (cs.name().equals("windows-1257"))
|
||||
|| (cs.name().equals("windows-1258"))
|
||||
|| (cs.name().equals("windows-932"))
|
||||
|| (cs.name().equals("x-mswin-936"))
|
||||
|| (cs.name().equals("x-windows-949"))
|
||||
|| (cs.name().equals("x-windows-950"))
|
||||
|| (cs.name().equals("windows-31j"))
|
||||
|| (cs.name().equals("Big5"))
|
||||
|| (cs.name().equals("Big5-HKSCS"))
|
||||
|| (cs.name().equals("x-MS950-HKSCS"))
|
||||
|| (cs.name().equals("ISO-2022-JP"))
|
||||
|| (cs.name().equals("ISO-2022-KR"))
|
||||
|| (cs.name().equals("x-ISO-2022-CN-CNS"))
|
||||
|| (cs.name().equals("x-ISO-2022-CN-GB"))
|
||||
|| (cs.name().equals("Big5-HKSCS"))
|
||||
|| (cs.name().equals("x-Johab"))
|
||||
|| (cs.name().equals("Shift_JIS")));
|
||||
}
|
||||
}
|
||||
135
jdkSrc/jdk8/sun/nio/cs/UnicodeDecoder.java
Normal file
135
jdkSrc/jdk8/sun/nio/cs/UnicodeDecoder.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.MalformedInputException;
|
||||
|
||||
|
||||
abstract class UnicodeDecoder extends CharsetDecoder {
|
||||
|
||||
protected static final char BYTE_ORDER_MARK = (char) 0xfeff;
|
||||
protected static final char REVERSED_MARK = (char) 0xfffe;
|
||||
|
||||
protected static final int NONE = 0;
|
||||
protected static final int BIG = 1;
|
||||
protected static final int LITTLE = 2;
|
||||
|
||||
private final int expectedByteOrder;
|
||||
private int currentByteOrder;
|
||||
private int defaultByteOrder = BIG;
|
||||
|
||||
public UnicodeDecoder(Charset cs, int bo) {
|
||||
super(cs, 0.5f, 1.0f);
|
||||
expectedByteOrder = currentByteOrder = bo;
|
||||
}
|
||||
|
||||
public UnicodeDecoder(Charset cs, int bo, int defaultBO) {
|
||||
this(cs, bo);
|
||||
defaultByteOrder = defaultBO;
|
||||
}
|
||||
|
||||
private char decode(int b1, int b2) {
|
||||
if (currentByteOrder == BIG)
|
||||
return (char)((b1 << 8) | b2);
|
||||
else
|
||||
return (char)((b2 << 8) | b1);
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
|
||||
int mark = src.position();
|
||||
|
||||
try {
|
||||
while (src.remaining() > 1) {
|
||||
int b1 = src.get() & 0xff;
|
||||
int b2 = src.get() & 0xff;
|
||||
|
||||
// Byte Order Mark interpretation
|
||||
if (currentByteOrder == NONE) {
|
||||
char c = (char)((b1 << 8) | b2);
|
||||
if (c == BYTE_ORDER_MARK) {
|
||||
currentByteOrder = BIG;
|
||||
mark += 2;
|
||||
continue;
|
||||
} else if (c == REVERSED_MARK) {
|
||||
currentByteOrder = LITTLE;
|
||||
mark += 2;
|
||||
continue;
|
||||
} else {
|
||||
currentByteOrder = defaultByteOrder;
|
||||
// FALL THROUGH to process b1, b2 normally
|
||||
}
|
||||
}
|
||||
|
||||
char c = decode(b1, b2);
|
||||
|
||||
if (c == REVERSED_MARK) {
|
||||
// A reversed BOM cannot occur within middle of stream
|
||||
return CoderResult.malformedForLength(2);
|
||||
}
|
||||
|
||||
// Surrogates
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (Character.isHighSurrogate(c)) {
|
||||
if (src.remaining() < 2)
|
||||
return CoderResult.UNDERFLOW;
|
||||
char c2 = decode(src.get() & 0xff, src.get() & 0xff);
|
||||
if (!Character.isLowSurrogate(c2))
|
||||
return CoderResult.malformedForLength(4);
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark += 4;
|
||||
dst.put(c);
|
||||
dst.put(c2);
|
||||
continue;
|
||||
}
|
||||
// Unpaired low surrogate
|
||||
return CoderResult.malformedForLength(2);
|
||||
}
|
||||
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
mark += 2;
|
||||
dst.put(c);
|
||||
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected void implReset() {
|
||||
currentByteOrder = expectedByteOrder;
|
||||
}
|
||||
|
||||
}
|
||||
111
jdkSrc/jdk8/sun/nio/cs/UnicodeEncoder.java
Normal file
111
jdkSrc/jdk8/sun/nio/cs/UnicodeEncoder.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.*;
|
||||
import java.nio.charset.*;
|
||||
|
||||
/**
|
||||
* Base class for different flavors of UTF-16 encoders
|
||||
*/
|
||||
public abstract class UnicodeEncoder extends CharsetEncoder {
|
||||
|
||||
protected static final char BYTE_ORDER_MARK = '\uFEFF';
|
||||
protected static final char REVERSED_MARK = '\uFFFE';
|
||||
|
||||
protected static final int BIG = 0;
|
||||
protected static final int LITTLE = 1;
|
||||
|
||||
private int byteOrder; /* Byte order in use */
|
||||
private boolean usesMark; /* Write an initial BOM */
|
||||
private boolean needsMark;
|
||||
|
||||
protected UnicodeEncoder(Charset cs, int bo, boolean m) {
|
||||
super(cs, 2.0f,
|
||||
// Four bytes max if you need a BOM
|
||||
m ? 4.0f : 2.0f,
|
||||
// Replacement depends upon byte order
|
||||
((bo == BIG)
|
||||
? new byte[] { (byte)0xff, (byte)0xfd }
|
||||
: new byte[] { (byte)0xfd, (byte)0xff }));
|
||||
usesMark = needsMark = m;
|
||||
byteOrder = bo;
|
||||
}
|
||||
|
||||
private void put(char c, ByteBuffer dst) {
|
||||
if (byteOrder == BIG) {
|
||||
dst.put((byte)(c >> 8));
|
||||
dst.put((byte)(c & 0xff));
|
||||
} else {
|
||||
dst.put((byte)(c & 0xff));
|
||||
dst.put((byte)(c >> 8));
|
||||
}
|
||||
}
|
||||
|
||||
private final Surrogate.Parser sgp = new Surrogate.Parser();
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
|
||||
int mark = src.position();
|
||||
|
||||
if (needsMark && src.hasRemaining()) {
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
put(BYTE_ORDER_MARK, dst);
|
||||
needsMark = false;
|
||||
}
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (!Character.isSurrogate(c)) {
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark++;
|
||||
put(c, dst);
|
||||
continue;
|
||||
}
|
||||
int d = sgp.parse(c, src);
|
||||
if (d < 0)
|
||||
return sgp.error();
|
||||
if (dst.remaining() < 4)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark += 2;
|
||||
put(Character.highSurrogate(d), dst);
|
||||
put(Character.lowSurrogate(d), dst);
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected void implReset() {
|
||||
needsMark = usesMark;
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return ! Character.isSurrogate(c);
|
||||
}
|
||||
}
|
||||
2420
jdkSrc/jdk8/sun/nio/cs/ext/Big5.java
Normal file
2420
jdkSrc/jdk8/sun/nio/cs/ext/Big5.java
Normal file
File diff suppressed because it is too large
Load Diff
89
jdkSrc/jdk8/sun/nio/cs/ext/Big5_HKSCS.java
Normal file
89
jdkSrc/jdk8/sun/nio/cs/ext/Big5_HKSCS.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class Big5_HKSCS extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public Big5_HKSCS() {
|
||||
super("Big5-HKSCS", ExtendedCharsets.aliasesFor("Big5-HKSCS"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Big5_HKSCS";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII"))
|
||||
|| (cs instanceof Big5)
|
||||
|| (cs instanceof Big5_HKSCS));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
static class Decoder extends HKSCS.Decoder {
|
||||
private static DoubleByte.Decoder big5 =
|
||||
(DoubleByte.Decoder)new Big5().newDecoder();
|
||||
|
||||
private static char[][] b2cBmp = new char[0x100][];
|
||||
private static char[][] b2cSupp = new char[0x100][];
|
||||
static {
|
||||
initb2c(b2cBmp, HKSCSMapping.b2cBmpStr);
|
||||
initb2c(b2cSupp, HKSCSMapping.b2cSuppStr);
|
||||
}
|
||||
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, big5, b2cBmp, b2cSupp);
|
||||
}
|
||||
}
|
||||
|
||||
static class Encoder extends HKSCS.Encoder {
|
||||
private static DoubleByte.Encoder big5 =
|
||||
(DoubleByte.Encoder)new Big5().newEncoder();
|
||||
|
||||
static char[][] c2bBmp = new char[0x100][];
|
||||
static char[][] c2bSupp = new char[0x100][];
|
||||
static {
|
||||
initc2b(c2bBmp, HKSCSMapping.b2cBmpStr, HKSCSMapping.pua);
|
||||
initc2b(c2bSupp, HKSCSMapping.b2cSuppStr, null);
|
||||
}
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, big5, c2bBmp, c2bSupp);
|
||||
}
|
||||
}
|
||||
}
|
||||
85
jdkSrc/jdk8/sun/nio/cs/ext/Big5_HKSCS_2001.java
Normal file
85
jdkSrc/jdk8/sun/nio/cs/ext/Big5_HKSCS_2001.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
|
||||
public class Big5_HKSCS_2001 extends Charset
|
||||
{
|
||||
public Big5_HKSCS_2001() {
|
||||
super("x-Big5-HKSCS-2001", ExtendedCharsets.aliasesFor("x-Big5-HKSCS-2001"));
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII"))
|
||||
|| (cs instanceof Big5)
|
||||
|| (cs instanceof Big5_HKSCS_2001));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends HKSCS.Decoder {
|
||||
private static DoubleByte.Decoder big5 =
|
||||
(DoubleByte.Decoder)new Big5().newDecoder();
|
||||
|
||||
private static char[][] b2cBmp = new char[0x100][];
|
||||
private static char[][] b2cSupp = new char[0x100][];
|
||||
static {
|
||||
initb2c(b2cBmp, HKSCS2001Mapping.b2cBmpStr);
|
||||
initb2c(b2cSupp, HKSCS2001Mapping.b2cSuppStr);
|
||||
}
|
||||
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, big5, b2cBmp, b2cSupp);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends HKSCS.Encoder {
|
||||
private static DoubleByte.Encoder big5 =
|
||||
(DoubleByte.Encoder)new Big5().newEncoder();
|
||||
|
||||
static char[][] c2bBmp = new char[0x100][];
|
||||
static char[][] c2bSupp = new char[0x100][];
|
||||
static {
|
||||
initc2b(c2bBmp, HKSCS2001Mapping.b2cBmpStr,
|
||||
HKSCS2001Mapping.pua);
|
||||
initc2b(c2bSupp, HKSCS2001Mapping.b2cSuppStr, null);
|
||||
}
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, big5, c2bBmp, c2bSupp);
|
||||
}
|
||||
}
|
||||
}
|
||||
126
jdkSrc/jdk8/sun/nio/cs/ext/Big5_Solaris.java
Normal file
126
jdkSrc/jdk8/sun/nio/cs/ext/Big5_Solaris.java
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import java.util.Arrays;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class Big5_Solaris extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public Big5_Solaris() {
|
||||
super("x-Big5-Solaris", ExtendedCharsets.aliasesFor("x-Big5-Solaris"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Big5_Solaris";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII"))
|
||||
|| (cs instanceof Big5)
|
||||
|| (cs instanceof Big5_Solaris));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
initb2c();
|
||||
return new DoubleByte.Decoder(this, b2c, b2cSB, 0x40, 0xfe);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
initc2b();
|
||||
return new DoubleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
static char[][] b2c;
|
||||
static char[] b2cSB;
|
||||
private static volatile boolean b2cInitialized = false;
|
||||
|
||||
static void initb2c() {
|
||||
if (b2cInitialized)
|
||||
return;
|
||||
synchronized (Big5_Solaris.class) {
|
||||
if (b2cInitialized)
|
||||
return;
|
||||
Big5.initb2c();
|
||||
b2c = Big5.b2c.clone();
|
||||
// Big5 Solaris implementation has 7 additional mappings
|
||||
int[] sol = new int[] {
|
||||
0xF9D6, 0x7881,
|
||||
0xF9D7, 0x92B9,
|
||||
0xF9D8, 0x88CF,
|
||||
0xF9D9, 0x58BB,
|
||||
0xF9DA, 0x6052,
|
||||
0xF9DB, 0x7CA7,
|
||||
0xF9DC, 0x5AFA };
|
||||
if (b2c[0xf9] == DoubleByte.B2C_UNMAPPABLE) {
|
||||
b2c[0xf9] = new char[0xfe - 0x40 + 1];
|
||||
Arrays.fill(b2c[0xf9], UNMAPPABLE_DECODING);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sol.length;) {
|
||||
b2c[0xf9][sol[i++] & 0xff - 0x40] = (char)sol[i++];
|
||||
}
|
||||
b2cSB = Big5.b2cSB;
|
||||
b2cInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
static char[] c2b;
|
||||
static char[] c2bIndex;
|
||||
private static volatile boolean c2bInitialized = false;
|
||||
|
||||
static void initc2b() {
|
||||
if (c2bInitialized)
|
||||
return;
|
||||
synchronized (Big5_Solaris.class) {
|
||||
if (c2bInitialized)
|
||||
return;
|
||||
Big5.initc2b();
|
||||
c2b = Big5.c2b.clone();
|
||||
c2bIndex = Big5.c2bIndex.clone();
|
||||
int[] sol = new int[] {
|
||||
0x7881, 0xF9D6,
|
||||
0x92B9, 0xF9D7,
|
||||
0x88CF, 0xF9D8,
|
||||
0x58BB, 0xF9D9,
|
||||
0x6052, 0xF9DA,
|
||||
0x7CA7, 0xF9DB,
|
||||
0x5AFA, 0xF9DC };
|
||||
|
||||
for (int i = 0; i < sol.length;) {
|
||||
int c = sol[i++];
|
||||
// no need to check c2bIndex[c >>8], we know it points
|
||||
// to the appropriate place.
|
||||
c2b[c2bIndex[c >> 8] + (c & 0xff)] = (char)sol[i++];
|
||||
}
|
||||
c2bInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
jdkSrc/jdk8/sun/nio/cs/ext/DelegatableDecoder.java
Normal file
41
jdkSrc/jdk8/sun/nio/cs/ext/DelegatableDecoder.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CoderResult;
|
||||
|
||||
/**
|
||||
* A decoder that can be delegated to by another decoder
|
||||
* when normal inheritance cannot be used.
|
||||
* Used by autodecting decoders.
|
||||
*/
|
||||
interface DelegatableDecoder {
|
||||
CoderResult decodeLoop(ByteBuffer src, CharBuffer dst);
|
||||
void implReset();
|
||||
CoderResult implFlush(CharBuffer out);
|
||||
}
|
||||
929
jdkSrc/jdk8/sun/nio/cs/ext/DoubleByte.java
Normal file
929
jdkSrc/jdk8/sun/nio/cs/ext/DoubleByte.java
Normal file
@@ -0,0 +1,929 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.Arrays;
|
||||
import sun.nio.cs.Surrogate;
|
||||
import sun.nio.cs.ArrayDecoder;
|
||||
import sun.nio.cs.ArrayEncoder;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
/*
|
||||
* Four types of "DoubleByte" charsets are implemented in this class
|
||||
* (1)DoubleByte
|
||||
* The "mostly widely used" multibyte charset, a combination of
|
||||
* a singlebyte character set (usually the ASCII charset) and a
|
||||
* doublebyte character set. The codepoint values of singlebyte
|
||||
* and doublebyte don't overlap. Microsoft's multibyte charsets
|
||||
* and IBM's "DBCS_ASCII" charsets, such as IBM1381, 942, 943,
|
||||
* 948, 949 and 950 are such charsets.
|
||||
*
|
||||
* (2)DoubleByte_EBCDIC
|
||||
* IBM EBCDIC Mix multibyte charset. Use SO and SI to shift (switch)
|
||||
* in and out between the singlebyte character set and doublebyte
|
||||
* character set.
|
||||
*
|
||||
* (3)DoubleByte_SIMPLE_EUC
|
||||
* It's a "simple" form of EUC encoding scheme, only have the
|
||||
* singlebyte character set G0 and one doublebyte character set
|
||||
* G1 are defined, G2 (with SS2) and G3 (with SS3) are not used.
|
||||
* So it is actually the same as the "typical" type (1) mentioned
|
||||
* above, except it return "malformed" for the SS2 and SS3 when
|
||||
* decoding.
|
||||
*
|
||||
* (4)DoubleByte ONLY
|
||||
* A "pure" doublebyte only character set. From implementation
|
||||
* point of view, this is the type (1) with "decodeSingle" always
|
||||
* returns unmappable.
|
||||
*
|
||||
* For simplicity, all implementations share the same decoding and
|
||||
* encoding data structure.
|
||||
*
|
||||
* Decoding:
|
||||
*
|
||||
* char[][] b2c;
|
||||
* char[] b2cSB;
|
||||
* int b2Min, b2Max
|
||||
*
|
||||
* public char decodeSingle(int b) {
|
||||
* return b2cSB.[b];
|
||||
* }
|
||||
*
|
||||
* public char decodeDouble(int b1, int b2) {
|
||||
* if (b2 < b2Min || b2 > b2Max)
|
||||
* return UNMAPPABLE_DECODING;
|
||||
* return b2c[b1][b2 - b2Min];
|
||||
* }
|
||||
*
|
||||
* (1)b2Min, b2Max are the corresponding min and max value of the
|
||||
* low-half of the double-byte.
|
||||
* (2)The high 8-bit/b1 of the double-byte are used to indexed into
|
||||
* b2c array.
|
||||
*
|
||||
* Encoding:
|
||||
*
|
||||
* char[] c2b;
|
||||
* char[] c2bIndex;
|
||||
*
|
||||
* public int encodeChar(char ch) {
|
||||
* return c2b[c2bIndex[ch >> 8] + (ch & 0xff)];
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
public class DoubleByte {
|
||||
|
||||
public final static char[] B2C_UNMAPPABLE;
|
||||
static {
|
||||
B2C_UNMAPPABLE = new char[0x100];
|
||||
Arrays.fill(B2C_UNMAPPABLE, UNMAPPABLE_DECODING);
|
||||
}
|
||||
|
||||
public static class Decoder extends CharsetDecoder
|
||||
implements DelegatableDecoder, ArrayDecoder
|
||||
{
|
||||
final char[][] b2c;
|
||||
final char[] b2cSB;
|
||||
final int b2Min;
|
||||
final int b2Max;
|
||||
|
||||
// for SimpleEUC override
|
||||
protected CoderResult crMalformedOrUnderFlow(int b) {
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
protected CoderResult crMalformedOrUnmappable(int b1, int b2) {
|
||||
if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte(b1)
|
||||
b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte(b2)
|
||||
decodeSingle(b2) != UNMAPPABLE_DECODING) { // isSingle(b2)
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
|
||||
Decoder(Charset cs, float avgcpb, float maxcpb,
|
||||
char[][] b2c, char[] b2cSB,
|
||||
int b2Min, int b2Max) {
|
||||
super(cs, avgcpb, maxcpb);
|
||||
this.b2c = b2c;
|
||||
this.b2cSB = b2cSB;
|
||||
this.b2Min = b2Min;
|
||||
this.b2Max = b2Max;
|
||||
}
|
||||
|
||||
Decoder(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max) {
|
||||
this(cs, 0.5f, 1.0f, b2c, b2cSB, b2Min, b2Max);
|
||||
}
|
||||
|
||||
protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
while (sp < sl && dp < dl) {
|
||||
// inline the decodeSingle/Double() for better performance
|
||||
int inSize = 1;
|
||||
int b1 = sa[sp] & 0xff;
|
||||
char c = b2cSB[b1];
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
if (sl - sp < 2)
|
||||
return crMalformedOrUnderFlow(b1);
|
||||
int b2 = sa[sp + 1] & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) {
|
||||
return crMalformedOrUnmappable(b1, b2);
|
||||
}
|
||||
inSize++;
|
||||
}
|
||||
da[dp++] = c;
|
||||
sp += inSize;
|
||||
}
|
||||
return (sp >= sl) ? CoderResult.UNDERFLOW
|
||||
: CoderResult.OVERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
|
||||
while (src.hasRemaining() && dst.hasRemaining()) {
|
||||
int b1 = src.get() & 0xff;
|
||||
char c = b2cSB[b1];
|
||||
int inSize = 1;
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
if (src.remaining() < 1)
|
||||
return crMalformedOrUnderFlow(b1);
|
||||
int b2 = src.get() & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING)
|
||||
return crMalformedOrUnmappable(b1, b2);
|
||||
inSize++;
|
||||
}
|
||||
dst.put(c);
|
||||
mark += inSize;
|
||||
}
|
||||
return src.hasRemaining()? CoderResult.OVERFLOW
|
||||
: CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
// Make some protected methods public for use by JISAutoDetect
|
||||
public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
public int decode(byte[] src, int sp, int len, char[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
char repl = replacement().charAt(0);
|
||||
while (sp < sl) {
|
||||
int b1 = src[sp++] & 0xff;
|
||||
char c = b2cSB[b1];
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
if (sp < sl) {
|
||||
int b2 = src[sp++] & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) {
|
||||
if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte
|
||||
b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte
|
||||
decodeSingle(b2) != UNMAPPABLE_DECODING) {
|
||||
sp--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
c = repl;
|
||||
}
|
||||
}
|
||||
dst[dp++] = c;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
|
||||
public void implReset() {
|
||||
super.implReset();
|
||||
}
|
||||
|
||||
public CoderResult implFlush(CharBuffer out) {
|
||||
return super.implFlush(out);
|
||||
}
|
||||
|
||||
// decode loops are not using decodeSingle/Double() for performance
|
||||
// reason.
|
||||
public char decodeSingle(int b) {
|
||||
return b2cSB[b];
|
||||
}
|
||||
|
||||
public char decodeDouble(int b1, int b2) {
|
||||
if (b1 < 0 || b1 > b2c.length ||
|
||||
b2 < b2Min || b2 > b2Max)
|
||||
return UNMAPPABLE_DECODING;
|
||||
return b2c[b1][b2 - b2Min];
|
||||
}
|
||||
}
|
||||
|
||||
// IBM_EBCDIC_DBCS
|
||||
public static class Decoder_EBCDIC extends Decoder {
|
||||
private static final int SBCS = 0;
|
||||
private static final int DBCS = 1;
|
||||
private static final int SO = 0x0e;
|
||||
private static final int SI = 0x0f;
|
||||
private int currentState;
|
||||
|
||||
Decoder_EBCDIC(Charset cs,
|
||||
char[][] b2c, char[] b2cSB, int b2Min, int b2Max) {
|
||||
super(cs, b2c, b2cSB, b2Min, b2Max);
|
||||
}
|
||||
|
||||
public void implReset() {
|
||||
currentState = SBCS;
|
||||
}
|
||||
|
||||
// Check validity of dbcs ebcdic byte pair values
|
||||
//
|
||||
// First byte : 0x41 -- 0xFE
|
||||
// Second byte: 0x41 -- 0xFE
|
||||
// Doublebyte blank: 0x4040
|
||||
//
|
||||
// The validation implementation in "old" DBCS_IBM_EBCDIC and sun.io
|
||||
// as
|
||||
// if ((b1 != 0x40 || b2 != 0x40) &&
|
||||
// (b2 < 0x41 || b2 > 0xfe)) {...}
|
||||
// is not correct/complete (range check for b1)
|
||||
//
|
||||
private static boolean isDoubleByte(int b1, int b2) {
|
||||
return (0x41 <= b1 && b1 <= 0xfe && 0x41 <= b2 && b2 <= 0xfe)
|
||||
|| (b1 == 0x40 && b2 == 0x40); // DBCS-HOST SPACE
|
||||
}
|
||||
|
||||
protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
// don't check dp/dl together here, it's possible to
|
||||
// decdoe a SO/SI without space in output buffer.
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp] & 0xff;
|
||||
int inSize = 1;
|
||||
if (b1 == SO) { // Shift out
|
||||
if (currentState != SBCS)
|
||||
return CoderResult.malformedForLength(1);
|
||||
else
|
||||
currentState = DBCS;
|
||||
} else if (b1 == SI) {
|
||||
if (currentState != DBCS)
|
||||
return CoderResult.malformedForLength(1);
|
||||
else
|
||||
currentState = SBCS;
|
||||
} else {
|
||||
char c = UNMAPPABLE_DECODING;
|
||||
if (currentState == SBCS) {
|
||||
c = b2cSB[b1];
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
return CoderResult.unmappableForLength(1);
|
||||
} else {
|
||||
if (sl - sp < 2)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int b2 = sa[sp + 1] & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) {
|
||||
if (!isDoubleByte(b1, b2))
|
||||
return CoderResult.malformedForLength(2);
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
inSize++;
|
||||
}
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
|
||||
da[dp++] = c;
|
||||
}
|
||||
sp += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
int b1 = src.get() & 0xff;
|
||||
int inSize = 1;
|
||||
if (b1 == SO) { // Shift out
|
||||
if (currentState != SBCS)
|
||||
return CoderResult.malformedForLength(1);
|
||||
else
|
||||
currentState = DBCS;
|
||||
} else if (b1 == SI) {
|
||||
if (currentState != DBCS)
|
||||
return CoderResult.malformedForLength(1);
|
||||
else
|
||||
currentState = SBCS;
|
||||
} else {
|
||||
char c = UNMAPPABLE_DECODING;
|
||||
if (currentState == SBCS) {
|
||||
c = b2cSB[b1];
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
return CoderResult.unmappableForLength(1);
|
||||
} else {
|
||||
if (src.remaining() < 1)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int b2 = src.get()&0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) {
|
||||
if (!isDoubleByte(b1, b2))
|
||||
return CoderResult.malformedForLength(2);
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
inSize++;
|
||||
}
|
||||
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
|
||||
dst.put(c);
|
||||
}
|
||||
mark += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
public int decode(byte[] src, int sp, int len, char[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
currentState = SBCS;
|
||||
char repl = replacement().charAt(0);
|
||||
while (sp < sl) {
|
||||
int b1 = src[sp++] & 0xff;
|
||||
if (b1 == SO) { // Shift out
|
||||
if (currentState != SBCS)
|
||||
dst[dp++] = repl;
|
||||
else
|
||||
currentState = DBCS;
|
||||
} else if (b1 == SI) {
|
||||
if (currentState != DBCS)
|
||||
dst[dp++] = repl;
|
||||
else
|
||||
currentState = SBCS;
|
||||
} else {
|
||||
char c = UNMAPPABLE_DECODING;
|
||||
if (currentState == SBCS) {
|
||||
c = b2cSB[b1];
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
c = repl;
|
||||
} else {
|
||||
if (sl == sp) {
|
||||
c = repl;
|
||||
} else {
|
||||
int b2 = src[sp++] & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) {
|
||||
c = repl;
|
||||
}
|
||||
}
|
||||
}
|
||||
dst[dp++] = c;
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
// DBCS_ONLY
|
||||
public static class Decoder_DBCSONLY extends Decoder {
|
||||
static final char[] b2cSB_UNMAPPABLE;
|
||||
static {
|
||||
b2cSB_UNMAPPABLE = new char[0x100];
|
||||
Arrays.fill(b2cSB_UNMAPPABLE, UNMAPPABLE_DECODING);
|
||||
}
|
||||
Decoder_DBCSONLY(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max) {
|
||||
super(cs, 0.5f, 1.0f, b2c, b2cSB_UNMAPPABLE, b2Min, b2Max);
|
||||
}
|
||||
}
|
||||
|
||||
// EUC_SIMPLE
|
||||
// The only thing we need to "override" is to check SS2/SS3 and
|
||||
// return "malformed" if found
|
||||
public static class Decoder_EUC_SIM extends Decoder {
|
||||
private final int SS2 = 0x8E;
|
||||
private final int SS3 = 0x8F;
|
||||
|
||||
Decoder_EUC_SIM(Charset cs,
|
||||
char[][] b2c, char[] b2cSB, int b2Min, int b2Max) {
|
||||
super(cs, b2c, b2cSB, b2Min, b2Max);
|
||||
}
|
||||
|
||||
// No support provided for G2/G3 for SimpleEUC
|
||||
protected CoderResult crMalformedOrUnderFlow(int b) {
|
||||
if (b == SS2 || b == SS3 )
|
||||
return CoderResult.malformedForLength(1);
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
protected CoderResult crMalformedOrUnmappable(int b1, int b2) {
|
||||
if (b1 == SS2 || b1 == SS3 )
|
||||
return CoderResult.malformedForLength(1);
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
|
||||
public int decode(byte[] src, int sp, int len, char[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
char repl = replacement().charAt(0);
|
||||
while (sp < sl) {
|
||||
int b1 = src[sp++] & 0xff;
|
||||
char c = b2cSB[b1];
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
if (sp < sl) {
|
||||
int b2 = src[sp++] & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max ||
|
||||
(c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) {
|
||||
if (b1 == SS2 || b1 == SS3) {
|
||||
sp--;
|
||||
}
|
||||
c = repl;
|
||||
}
|
||||
} else {
|
||||
c = repl;
|
||||
}
|
||||
}
|
||||
dst[dp++] = c;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Encoder extends CharsetEncoder
|
||||
implements ArrayEncoder
|
||||
{
|
||||
final int MAX_SINGLEBYTE = 0xff;
|
||||
private final char[] c2b;
|
||||
private final char[] c2bIndex;
|
||||
Surrogate.Parser sgp;
|
||||
|
||||
protected Encoder(Charset cs, char[] c2b, char[] c2bIndex) {
|
||||
super(cs, 2.0f, 2.0f);
|
||||
this.c2b = c2b;
|
||||
this.c2bIndex = c2bIndex;
|
||||
}
|
||||
|
||||
Encoder(Charset cs, float avg, float max, byte[] repl, char[] c2b, char[] c2bIndex) {
|
||||
super(cs, avg, max, repl);
|
||||
this.c2b = c2b;
|
||||
this.c2bIndex = c2bIndex;
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return encodeChar(c) != UNMAPPABLE_ENCODING;
|
||||
}
|
||||
|
||||
Surrogate.Parser sgp() {
|
||||
if (sgp == null)
|
||||
sgp = new Surrogate.Parser();
|
||||
return sgp;
|
||||
}
|
||||
|
||||
protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp().parse(c, sa, sp, sl) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
if (dl - dp < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte)(bb >> 8);
|
||||
da[dp++] = (byte)bb;
|
||||
} else { // SingleByte
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte)bb;
|
||||
}
|
||||
|
||||
sp++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp().parse(c, src) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)(bb >> 8));
|
||||
dst.put((byte)(bb));
|
||||
} else {
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)bb);
|
||||
}
|
||||
mark++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
protected byte[] repl = replacement();
|
||||
protected void implReplaceWith(byte[] newReplacement) {
|
||||
repl = newReplacement;
|
||||
}
|
||||
|
||||
public int encode(char[] src, int sp, int len, byte[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
int dl = dst.length;
|
||||
while (sp < sl) {
|
||||
char c = src[sp++];
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isHighSurrogate(c) && sp < sl &&
|
||||
Character.isLowSurrogate(src[sp])) {
|
||||
sp++;
|
||||
}
|
||||
dst[dp++] = repl[0];
|
||||
if (repl.length > 1)
|
||||
dst[dp++] = repl[1];
|
||||
continue;
|
||||
} //else
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
dst[dp++] = (byte)(bb >> 8);
|
||||
dst[dp++] = (byte)bb;
|
||||
} else { // SingleByte
|
||||
dst[dp++] = (byte)bb;
|
||||
}
|
||||
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
|
||||
public int encodeChar(char ch) {
|
||||
return c2b[c2bIndex[ch >> 8] + (ch & 0xff)];
|
||||
}
|
||||
|
||||
// init the c2b and c2bIndex tables from b2c.
|
||||
static void initC2B(String[] b2c, String b2cSB, String b2cNR, String c2bNR,
|
||||
int b2Min, int b2Max,
|
||||
char[] c2b, char[] c2bIndex)
|
||||
{
|
||||
Arrays.fill(c2b, (char)UNMAPPABLE_ENCODING);
|
||||
int off = 0x100;
|
||||
|
||||
char[][] b2c_ca = new char[b2c.length][];
|
||||
char[] b2cSB_ca = null;
|
||||
if (b2cSB != null)
|
||||
b2cSB_ca = b2cSB.toCharArray();
|
||||
|
||||
for (int i = 0; i < b2c.length; i++) {
|
||||
if (b2c[i] == null)
|
||||
continue;
|
||||
b2c_ca[i] = b2c[i].toCharArray();
|
||||
}
|
||||
|
||||
if (b2cNR != null) {
|
||||
int j = 0;
|
||||
while (j < b2cNR.length()) {
|
||||
char b = b2cNR.charAt(j++);
|
||||
char c = b2cNR.charAt(j++);
|
||||
if (b < 0x100 && b2cSB_ca != null) {
|
||||
if (b2cSB_ca[b] == c)
|
||||
b2cSB_ca[b] = UNMAPPABLE_DECODING;
|
||||
} else {
|
||||
if (b2c_ca[b >> 8][(b & 0xff) - b2Min] == c)
|
||||
b2c_ca[b >> 8][(b & 0xff) - b2Min] = UNMAPPABLE_DECODING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (b2cSB_ca != null) { // SingleByte
|
||||
for (int b = 0; b < b2cSB_ca.length; b++) {
|
||||
char c = b2cSB_ca[b];
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
continue;
|
||||
int index = c2bIndex[c >> 8];
|
||||
if (index == 0) {
|
||||
index = off;
|
||||
off += 0x100;
|
||||
c2bIndex[c >> 8] = (char)index;
|
||||
}
|
||||
c2b[index + (c & 0xff)] = (char)b;
|
||||
}
|
||||
}
|
||||
|
||||
for (int b1 = 0; b1 < b2c.length; b1++) { // DoubleByte
|
||||
char[] db = b2c_ca[b1];
|
||||
if (db == null)
|
||||
continue;
|
||||
for (int b2 = b2Min; b2 <= b2Max; b2++) {
|
||||
char c = db[b2 - b2Min];
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
continue;
|
||||
int index = c2bIndex[c >> 8];
|
||||
if (index == 0) {
|
||||
index = off;
|
||||
off += 0x100;
|
||||
c2bIndex[c >> 8] = (char)index;
|
||||
}
|
||||
c2b[index + (c & 0xff)] = (char)((b1 << 8) | b2);
|
||||
}
|
||||
}
|
||||
|
||||
if (c2bNR != null) {
|
||||
// add c->b only nr entries
|
||||
for (int i = 0; i < c2bNR.length(); i += 2) {
|
||||
char b = c2bNR.charAt(i);
|
||||
char c = c2bNR.charAt(i + 1);
|
||||
int index = (c >> 8);
|
||||
if (c2bIndex[index] == 0) {
|
||||
c2bIndex[index] = (char)off;
|
||||
off += 0x100;
|
||||
}
|
||||
index = c2bIndex[index] + (c & 0xff);
|
||||
c2b[index] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Encoder_DBCSONLY extends Encoder {
|
||||
Encoder_DBCSONLY(Charset cs, byte[] repl,
|
||||
char[] c2b, char[] c2bIndex) {
|
||||
super(cs, 2.0f, 2.0f, repl, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
public int encodeChar(char ch) {
|
||||
int bb = super.encodeChar(ch);
|
||||
if (bb <= MAX_SINGLEBYTE)
|
||||
return UNMAPPABLE_ENCODING;
|
||||
return bb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class Encoder_EBCDIC extends Encoder {
|
||||
static final int SBCS = 0;
|
||||
static final int DBCS = 1;
|
||||
static final byte SO = 0x0e;
|
||||
static final byte SI = 0x0f;
|
||||
|
||||
protected int currentState = SBCS;
|
||||
|
||||
Encoder_EBCDIC(Charset cs, char[] c2b, char[] c2bIndex) {
|
||||
super(cs, 4.0f, 5.0f, new byte[] {(byte)0x6f}, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
protected void implReset() {
|
||||
currentState = SBCS;
|
||||
}
|
||||
|
||||
protected CoderResult implFlush(ByteBuffer out) {
|
||||
if (currentState == DBCS) {
|
||||
if (out.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
out.put(SI);
|
||||
}
|
||||
implReset();
|
||||
return CoderResult.UNDERFLOW;
|
||||
}
|
||||
|
||||
protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp().parse(c, sa, sp, sl) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
if (currentState == SBCS) {
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
currentState = DBCS;
|
||||
da[dp++] = SO;
|
||||
}
|
||||
if (dl - dp < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte)(bb >> 8);
|
||||
da[dp++] = (byte)bb;
|
||||
} else { // SingleByte
|
||||
if (currentState == DBCS) {
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
currentState = SBCS;
|
||||
da[dp++] = SI;
|
||||
}
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte)bb;
|
||||
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp().parse(c, src) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
if (currentState == SBCS) {
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
currentState = DBCS;
|
||||
dst.put(SO);
|
||||
}
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)(bb >> 8));
|
||||
dst.put((byte)(bb));
|
||||
} else { // Single-byte
|
||||
if (currentState == DBCS) {
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
currentState = SBCS;
|
||||
dst.put(SI);
|
||||
}
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)bb);
|
||||
}
|
||||
mark++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
public int encode(char[] src, int sp, int len, byte[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
while (sp < sl) {
|
||||
char c = src[sp++];
|
||||
int bb = encodeChar(c);
|
||||
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isHighSurrogate(c) && sp < sl &&
|
||||
Character.isLowSurrogate(src[sp])) {
|
||||
sp++;
|
||||
}
|
||||
dst[dp++] = repl[0];
|
||||
if (repl.length > 1)
|
||||
dst[dp++] = repl[1];
|
||||
continue;
|
||||
} //else
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
if (currentState == SBCS) {
|
||||
currentState = DBCS;
|
||||
dst[dp++] = SO;
|
||||
}
|
||||
dst[dp++] = (byte)(bb >> 8);
|
||||
dst[dp++] = (byte)bb;
|
||||
} else { // SingleByte
|
||||
if (currentState == DBCS) {
|
||||
currentState = SBCS;
|
||||
dst[dp++] = SI;
|
||||
}
|
||||
dst[dp++] = (byte)bb;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentState == DBCS) {
|
||||
currentState = SBCS;
|
||||
dst[dp++] = SI;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
// EUC_SIMPLE
|
||||
public static class Encoder_EUC_SIM extends Encoder {
|
||||
Encoder_EUC_SIM(Charset cs, char[] c2b, char[] c2bIndex) {
|
||||
super(cs, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
241
jdkSrc/jdk8/sun/nio/cs/ext/DoubleByteEncoder.java
Normal file
241
jdkSrc/jdk8/sun/nio/cs/ext/DoubleByteEncoder.java
Normal file
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import sun.nio.cs.Surrogate;
|
||||
|
||||
public abstract class DoubleByteEncoder
|
||||
extends CharsetEncoder
|
||||
{
|
||||
|
||||
private short index1[];
|
||||
private String index2[];
|
||||
|
||||
private final Surrogate.Parser sgp = new Surrogate.Parser();
|
||||
|
||||
protected DoubleByteEncoder(Charset cs,
|
||||
short[] index1, String[] index2)
|
||||
{
|
||||
super(cs, 2.0f, 2.0f);
|
||||
this.index1 = index1;
|
||||
this.index2 = index2;
|
||||
}
|
||||
|
||||
protected DoubleByteEncoder(Charset cs,
|
||||
short[] index1, String[] index2,
|
||||
float avg, float max)
|
||||
{
|
||||
super(cs, avg, max);
|
||||
this.index1 = index1;
|
||||
this.index2 = index2;
|
||||
}
|
||||
|
||||
protected DoubleByteEncoder(Charset cs,
|
||||
short[] index1, String[] index2, byte[] repl)
|
||||
{
|
||||
super(cs, 2.0f, 2.0f, repl);
|
||||
this.index1 = index1;
|
||||
this.index2 = index2;
|
||||
}
|
||||
|
||||
|
||||
protected DoubleByteEncoder(Charset cs,
|
||||
short[] index1, String[] index2,
|
||||
byte[] repl, float avg, float max)
|
||||
{
|
||||
super(cs, avg, max,repl);
|
||||
this.index1 = index1;
|
||||
this.index2 = index2;
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return (encodeSingle(c) != -1 ||
|
||||
encodeDouble(c) != 0);
|
||||
}
|
||||
|
||||
private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp.parse(c, sa, sp, sl) < 0)
|
||||
return sgp.error();
|
||||
if (sl - sp < 2)
|
||||
return CoderResult.UNDERFLOW;
|
||||
char c2 = sa[sp + 1];
|
||||
|
||||
byte[] outputBytes = new byte[2];
|
||||
outputBytes = encodeSurrogate(c, c2);
|
||||
|
||||
if (outputBytes == null) {
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
else {
|
||||
if (dl - dp < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = outputBytes[0];
|
||||
da[dp++] = outputBytes[1];
|
||||
sp += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (c >= '\uFFFE')
|
||||
return CoderResult.unmappableForLength(1);
|
||||
|
||||
int b = encodeSingle(c);
|
||||
if (b != -1) { // Single Byte
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte)b;
|
||||
sp++;
|
||||
continue;
|
||||
}
|
||||
|
||||
int ncode = encodeDouble(c);
|
||||
if (ncode != 0 && c != '\u0000' ) {
|
||||
if (dl - dp < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte) ((ncode & 0xff00) >> 8);
|
||||
da[dp++] = (byte) (ncode & 0xff);
|
||||
sp++;
|
||||
continue;
|
||||
}
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
|
||||
int mark = src.position();
|
||||
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char c = src.get();
|
||||
if (Character.isSurrogate(c)) {
|
||||
int surr;
|
||||
if ((surr = sgp.parse(c, src)) < 0)
|
||||
return sgp.error();
|
||||
char c2 = Surrogate.low(surr);
|
||||
byte[] outputBytes = new byte[2];
|
||||
outputBytes = encodeSurrogate(c, c2);
|
||||
|
||||
if (outputBytes == null) {
|
||||
return sgp.unmappableResult();
|
||||
} else {
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark += 2;
|
||||
dst.put(outputBytes[0]);
|
||||
dst.put(outputBytes[1]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (c >= '\uFFFE')
|
||||
return CoderResult.unmappableForLength(1);
|
||||
int b = encodeSingle(c);
|
||||
|
||||
if (b != -1) { // Single-byte character
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark++;
|
||||
dst.put((byte)b);
|
||||
continue;
|
||||
}
|
||||
// Double Byte character
|
||||
|
||||
int ncode = encodeDouble(c);
|
||||
if (ncode != 0 && c != '\u0000') {
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
mark++;
|
||||
dst.put((byte) ((ncode & 0xff00) >> 8));
|
||||
dst.put((byte) ncode);
|
||||
continue;
|
||||
}
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
|
||||
if (true && src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
/*
|
||||
* Can be changed by subclass
|
||||
*/
|
||||
protected int encodeDouble(char ch) {
|
||||
int offset = index1[((ch & 0xff00) >> 8 )] << 8;
|
||||
return index2[offset >> 12].charAt((offset & 0xfff) + (ch & 0xff));
|
||||
}
|
||||
|
||||
/*
|
||||
* Can be changed by subclass
|
||||
*/
|
||||
protected int encodeSingle(char inputChar) {
|
||||
if (inputChar < 0x80)
|
||||
return (byte)inputChar;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected method which should be overridden by concrete DBCS
|
||||
* CharsetEncoder classes which included supplementary characters
|
||||
* within their mapping coverage.
|
||||
* null return value indicates surrogate values could not be
|
||||
* handled or encoded.
|
||||
*/
|
||||
protected byte[] encodeSurrogate(char highSurrogate, char lowSurrogate) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
1284
jdkSrc/jdk8/sun/nio/cs/ext/EUC_CN.java
Normal file
1284
jdkSrc/jdk8/sun/nio/cs/ext/EUC_CN.java
Normal file
File diff suppressed because it is too large
Load Diff
411
jdkSrc/jdk8/sun/nio/cs/ext/EUC_JP.java
Normal file
411
jdkSrc/jdk8/sun/nio/cs/ext/EUC_JP.java
Normal file
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import sun.nio.cs.Surrogate;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class EUC_JP
|
||||
extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
public EUC_JP() {
|
||||
super("EUC-JP", ExtendedCharsets.aliasesFor("EUC-JP"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "EUC_JP";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII"))
|
||||
|| (cs instanceof JIS_X_0201)
|
||||
|| (cs instanceof JIS_X_0208)
|
||||
|| (cs instanceof JIS_X_0212)
|
||||
|| (cs instanceof EUC_JP));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
static class Decoder extends CharsetDecoder
|
||||
implements DelegatableDecoder {
|
||||
|
||||
final static SingleByte.Decoder DEC0201 =
|
||||
(SingleByte.Decoder)new JIS_X_0201().newDecoder();
|
||||
|
||||
final static DoubleByte.Decoder DEC0208 =
|
||||
(DoubleByte.Decoder)new JIS_X_0208().newDecoder();
|
||||
|
||||
final static DoubleByte.Decoder DEC0212 =
|
||||
(DoubleByte.Decoder)new JIS_X_0212().newDecoder();
|
||||
|
||||
private final SingleByte.Decoder dec0201;
|
||||
private final DoubleByte.Decoder dec0208;
|
||||
private final DoubleByte.Decoder dec0212;
|
||||
|
||||
protected Decoder(Charset cs) {
|
||||
this(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212);
|
||||
}
|
||||
|
||||
protected Decoder(Charset cs, float avgCpb, float maxCpb,
|
||||
SingleByte.Decoder dec0201,
|
||||
DoubleByte.Decoder dec0208,
|
||||
DoubleByte.Decoder dec0212) {
|
||||
super(cs, avgCpb, maxCpb);
|
||||
this.dec0201 = dec0201;
|
||||
this.dec0208 = dec0208;
|
||||
this.dec0212 = dec0212;
|
||||
}
|
||||
|
||||
|
||||
protected char decodeDouble(int byte1, int byte2) {
|
||||
if (byte1 == 0x8e) {
|
||||
if (byte2 < 0x80)
|
||||
return UNMAPPABLE_DECODING;
|
||||
return dec0201.decode((byte)byte2);
|
||||
}
|
||||
return dec0208.decodeDouble(byte1 - 0x80, byte2 - 0x80);
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
assert (sp <= sl);
|
||||
sp = (sp <= sl ? sp : sl);
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
|
||||
int b1 = 0, b2 = 0;
|
||||
int inputSize = 0;
|
||||
char outputChar = UNMAPPABLE_DECODING;
|
||||
try {
|
||||
while (sp < sl) {
|
||||
b1 = sa[sp] & 0xff;
|
||||
inputSize = 1;
|
||||
|
||||
if ((b1 & 0x80) == 0) {
|
||||
outputChar = (char)b1;
|
||||
} else { // Multibyte char
|
||||
if (b1 == 0x8f) { // JIS0212
|
||||
if (sp + 3 > sl)
|
||||
return CoderResult.UNDERFLOW;
|
||||
b1 = sa[sp + 1] & 0xff;
|
||||
b2 = sa[sp + 2] & 0xff;
|
||||
inputSize += 2;
|
||||
if (dec0212 == null) // JIS02012 not supported
|
||||
return CoderResult.unmappableForLength(inputSize);
|
||||
outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80);
|
||||
} else { // JIS0201, JIS0208
|
||||
if (sp + 2 > sl)
|
||||
return CoderResult.UNDERFLOW;
|
||||
b2 = sa[sp + 1] & 0xff;
|
||||
inputSize++;
|
||||
outputChar = decodeDouble(b1, b2);
|
||||
}
|
||||
}
|
||||
if (outputChar == UNMAPPABLE_DECODING) { // can't be decoded
|
||||
return CoderResult.unmappableForLength(inputSize);
|
||||
}
|
||||
if (dp + 1 > dl)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = outputChar;
|
||||
sp += inputSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
int b1 = 0, b2 = 0;
|
||||
int inputSize = 0;
|
||||
char outputChar = UNMAPPABLE_DECODING;
|
||||
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
b1 = src.get() & 0xff;
|
||||
inputSize = 1;
|
||||
if ((b1 & 0x80) == 0) {
|
||||
outputChar = (char)b1;
|
||||
} else { // Multibyte char
|
||||
if (b1 == 0x8f) { // JIS0212
|
||||
if (src.remaining() < 2)
|
||||
return CoderResult.UNDERFLOW;
|
||||
b1 = src.get() & 0xff;
|
||||
b2 = src.get() & 0xff;
|
||||
inputSize += 2;
|
||||
if (dec0212 == null) // JIS02012 not supported
|
||||
return CoderResult.unmappableForLength(inputSize);
|
||||
outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80);
|
||||
} else { // JIS0201 JIS0208
|
||||
if (src.remaining() < 1)
|
||||
return CoderResult.UNDERFLOW;
|
||||
b2 = src.get() & 0xff;
|
||||
inputSize++;
|
||||
outputChar = decodeDouble(b1, b2);
|
||||
}
|
||||
}
|
||||
if (outputChar == UNMAPPABLE_DECODING) {
|
||||
return CoderResult.unmappableForLength(inputSize);
|
||||
}
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put(outputChar);
|
||||
mark += inputSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
// Make some protected methods public for use by JISAutoDetect
|
||||
public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
public void implReset() {
|
||||
super.implReset();
|
||||
}
|
||||
public CoderResult implFlush(CharBuffer out) {
|
||||
return super.implFlush(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class Encoder extends CharsetEncoder {
|
||||
|
||||
final static SingleByte.Encoder ENC0201 =
|
||||
(SingleByte.Encoder)new JIS_X_0201().newEncoder();
|
||||
|
||||
final static DoubleByte.Encoder ENC0208 =
|
||||
(DoubleByte.Encoder)new JIS_X_0208().newEncoder();
|
||||
|
||||
final static DoubleByte.Encoder ENC0212 =
|
||||
(DoubleByte.Encoder)new JIS_X_0212().newEncoder();
|
||||
|
||||
private final Surrogate.Parser sgp = new Surrogate.Parser();
|
||||
|
||||
|
||||
private final SingleByte.Encoder enc0201;
|
||||
private final DoubleByte.Encoder enc0208;
|
||||
private final DoubleByte.Encoder enc0212;
|
||||
|
||||
protected Encoder(Charset cs) {
|
||||
this(cs, 3.0f, 3.0f, ENC0201, ENC0208, ENC0212);
|
||||
}
|
||||
|
||||
protected Encoder(Charset cs, float avgBpc, float maxBpc,
|
||||
SingleByte.Encoder enc0201,
|
||||
DoubleByte.Encoder enc0208,
|
||||
DoubleByte.Encoder enc0212) {
|
||||
super(cs, avgBpc, maxBpc);
|
||||
this.enc0201 = enc0201;
|
||||
this.enc0208 = enc0208;
|
||||
this.enc0212 = enc0212;
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
byte[] encodedBytes = new byte[3];
|
||||
return encodeSingle(c, encodedBytes) != 0 ||
|
||||
encodeDouble(c) != UNMAPPABLE_ENCODING;
|
||||
}
|
||||
|
||||
protected int encodeSingle(char inputChar, byte[] outputByte) {
|
||||
int b = enc0201.encode(inputChar);
|
||||
if (b == UNMAPPABLE_ENCODING)
|
||||
return 0;
|
||||
if (b >= 0 && b < 128) {
|
||||
outputByte[0] = (byte)b;
|
||||
return 1;
|
||||
}
|
||||
outputByte[0] = (byte)0x8e;
|
||||
outputByte[1] = (byte)b;
|
||||
return 2;
|
||||
}
|
||||
|
||||
protected int encodeDouble(char ch) {
|
||||
int b = enc0208.encodeChar(ch);
|
||||
if (b != UNMAPPABLE_ENCODING)
|
||||
return b + 0x8080;
|
||||
if (enc0212 != null) {
|
||||
b = enc0212.encodeChar(ch);
|
||||
if (b != UNMAPPABLE_ENCODING)
|
||||
b += 0x8F8080;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
private CoderResult encodeArrayLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
assert (sp <= sl);
|
||||
sp = (sp <= sl ? sp : sl);
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
|
||||
int outputSize = 0;
|
||||
byte[] outputByte;
|
||||
int inputSize = 0; // Size of input
|
||||
byte[] tmpBuf = new byte[3];
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
outputByte = tmpBuf;
|
||||
char c = sa[sp];
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp.parse(c, sa, sp, sl) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
outputSize = encodeSingle(c, outputByte);
|
||||
if (outputSize == 0) { // DoubleByte
|
||||
int ncode = encodeDouble(c);
|
||||
if (ncode != UNMAPPABLE_ENCODING) {
|
||||
if ((ncode & 0xFF0000) == 0) {
|
||||
outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
|
||||
outputByte[1] = (byte) (ncode & 0xff);
|
||||
outputSize = 2;
|
||||
} else {
|
||||
outputByte[0] = (byte) 0x8f;
|
||||
outputByte[1] = (byte) ((ncode & 0xff00) >> 8);
|
||||
outputByte[2] = (byte) (ncode & 0xff);
|
||||
outputSize = 3;
|
||||
}
|
||||
} else {
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
}
|
||||
if (dl - dp < outputSize)
|
||||
return CoderResult.OVERFLOW;
|
||||
// Put the byte in the output buffer
|
||||
for (int i = 0; i < outputSize; i++) {
|
||||
da[dp++] = outputByte[i];
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
int outputSize = 0;
|
||||
byte[] outputByte;
|
||||
int inputSize = 0; // Size of input
|
||||
byte[] tmpBuf = new byte[3];
|
||||
|
||||
int mark = src.position();
|
||||
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
outputByte = tmpBuf;
|
||||
char c = src.get();
|
||||
if (Character.isSurrogate(c)) {
|
||||
if (sgp.parse(c, src) < 0)
|
||||
return sgp.error();
|
||||
return sgp.unmappableResult();
|
||||
}
|
||||
outputSize = encodeSingle(c, outputByte);
|
||||
if (outputSize == 0) { // DoubleByte
|
||||
int ncode = encodeDouble(c);
|
||||
if (ncode != UNMAPPABLE_ENCODING) {
|
||||
if ((ncode & 0xFF0000) == 0) {
|
||||
outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
|
||||
outputByte[1] = (byte) (ncode & 0xff);
|
||||
outputSize = 2;
|
||||
} else {
|
||||
outputByte[0] = (byte) 0x8f;
|
||||
outputByte[1] = (byte) ((ncode & 0xff00) >> 8);
|
||||
outputByte[2] = (byte) (ncode & 0xff);
|
||||
outputSize = 3;
|
||||
}
|
||||
} else {
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
}
|
||||
if (dst.remaining() < outputSize)
|
||||
return CoderResult.OVERFLOW;
|
||||
// Put the byte in the output buffer
|
||||
for (int i = 0; i < outputSize; i++) {
|
||||
dst.put(outputByte[i]);
|
||||
}
|
||||
mark++;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
73
jdkSrc/jdk8/sun/nio/cs/ext/EUC_JP_LINUX.java
Normal file
73
jdkSrc/jdk8/sun/nio/cs/ext/EUC_JP_LINUX.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
|
||||
public class EUC_JP_LINUX
|
||||
extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
public EUC_JP_LINUX() {
|
||||
super("x-euc-jp-linux", ExtendedCharsets.aliasesFor("x-euc-jp-linux"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "EUC_JP_LINUX";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs instanceof JIS_X_0201)
|
||||
|| (cs.name().equals("US-ASCII"))
|
||||
|| (cs instanceof EUC_JP_LINUX));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends EUC_JP.Decoder {
|
||||
private Decoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f, DEC0201, DEC0208, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends EUC_JP.Encoder {
|
||||
private Encoder(Charset cs) {
|
||||
super(cs, 2.0f, 2.0f, ENC0201, ENC0208, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
111
jdkSrc/jdk8/sun/nio/cs/ext/EUC_JP_Open.java
Normal file
111
jdkSrc/jdk8/sun/nio/cs/ext/EUC_JP_Open.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class EUC_JP_Open
|
||||
extends Charset
|
||||
implements HistoricallyNamedCharset
|
||||
{
|
||||
public EUC_JP_Open() {
|
||||
super("x-eucJP-Open", ExtendedCharsets.aliasesFor("x-eucJP-Open"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "EUC_JP_Solaris";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII"))
|
||||
|| (cs instanceof JIS_X_0201)
|
||||
|| (cs instanceof EUC_JP));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
private static class Decoder extends EUC_JP.Decoder {
|
||||
private static DoubleByte.Decoder DEC0208_Solaris =
|
||||
(DoubleByte.Decoder)new JIS_X_0208_Solaris().newDecoder();
|
||||
private static DoubleByte.Decoder DEC0212_Solaris =
|
||||
(DoubleByte.Decoder)new JIS_X_0212_Solaris().newDecoder();
|
||||
|
||||
private Decoder(Charset cs) {
|
||||
// JIS_X_0208_Solaris only has the "extra" mappings, it
|
||||
// does not have the JIS_X_0208 entries
|
||||
super(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212_Solaris);
|
||||
}
|
||||
|
||||
protected char decodeDouble(int byte1, int byte2) {
|
||||
char c = super.decodeDouble(byte1, byte2);
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
return DEC0208_Solaris.decodeDouble(byte1 - 0x80, byte2 - 0x80);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Encoder extends EUC_JP.Encoder {
|
||||
private static DoubleByte.Encoder ENC0208_Solaris =
|
||||
(DoubleByte.Encoder)new JIS_X_0208_Solaris().newEncoder();
|
||||
|
||||
private static DoubleByte.Encoder ENC0212_Solaris =
|
||||
(DoubleByte.Encoder)new JIS_X_0212_Solaris().newEncoder();
|
||||
|
||||
private Encoder(Charset cs) {
|
||||
// The EUC_JP_Open has some interesting tweak for the
|
||||
// encoding, so can't just pass the euc0208_solaris to
|
||||
// the euc_jp. Have to override the encodeDouble() as
|
||||
// showed below (mapping testing catches this).
|
||||
// super(cs, 3.0f, 3.0f, ENC0201, ENC0208_Solaris, ENC0212_Solaris);
|
||||
super(cs);
|
||||
}
|
||||
|
||||
protected int encodeDouble(char ch) {
|
||||
int b = super.encodeDouble(ch);
|
||||
if (b != UNMAPPABLE_ENCODING)
|
||||
return b;
|
||||
b = ENC0208_Solaris.encodeChar(ch);
|
||||
if (b != UNMAPPABLE_ENCODING && b > 0x7500) {
|
||||
return 0x8F8080 + ENC0212_Solaris.encodeChar(ch);
|
||||
}
|
||||
return b == UNMAPPABLE_ENCODING ? b : b + 0x8080;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
1372
jdkSrc/jdk8/sun/nio/cs/ext/EUC_KR.java
Normal file
1372
jdkSrc/jdk8/sun/nio/cs/ext/EUC_KR.java
Normal file
File diff suppressed because it is too large
Load Diff
546
jdkSrc/jdk8/sun/nio/cs/ext/EUC_TW.java
Normal file
546
jdkSrc/jdk8/sun/nio/cs/ext/EUC_TW.java
Normal file
@@ -0,0 +1,546 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.Arrays;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class EUC_TW extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
private static final int SS2 = 0x8E;
|
||||
|
||||
/*
|
||||
(1) EUC_TW
|
||||
Second byte of EUC_TW for cs2 is in range of
|
||||
0xA1-0xB0 for plane 1-16. According to CJKV /163,
|
||||
plane1 is coded in both cs1 and cs2. This impl
|
||||
however does not decode the codepoints of plane1
|
||||
in cs2, so only p2-p7 and p15 are supported in cs2.
|
||||
|
||||
Plane2 0xA2;
|
||||
Plane3 0xA3;
|
||||
Plane4 0xA4;
|
||||
Plane5 0xA5;
|
||||
Plane6 0xA6;
|
||||
Plane7 0xA7;
|
||||
Plane15 0xAF;
|
||||
|
||||
(2) Mapping
|
||||
The fact that all supplementary characters encoded in EUC_TW are
|
||||
in 0x2xxxx range gives us the room to optimize the data tables.
|
||||
|
||||
Decoding:
|
||||
(1) save the lower 16-bit value of all codepoints of b->c mapping
|
||||
in a String array table String[plane] b2c.
|
||||
(2) save "codepoint is supplementary" info (one bit) in a
|
||||
byte[] b2cIsSupp, so 8 codepoints (same codepoint value, different
|
||||
plane No) share one byte.
|
||||
|
||||
Encoding:
|
||||
(1)c->b mappings are stored in
|
||||
char[]c2b/char[]c2bIndex
|
||||
char[]c2bSupp/char[]c2bIndexsupp (indexed by lower 16-bit
|
||||
(2)byte[] c2bPlane stores the "plane info" of each euc-tw codepoints,
|
||||
BMP and Supp share the low/high 4 bits of one byte.
|
||||
|
||||
Mapping tables are stored separated in EUC_TWMapping, which
|
||||
is generated by tool.
|
||||
*/
|
||||
|
||||
public EUC_TW() {
|
||||
super("x-EUC-TW", ExtendedCharsets.aliasesFor("x-EUC-TW"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "EUC_TW";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return ((cs.name().equals("US-ASCII"))
|
||||
|| (cs instanceof EUC_TW));
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new Decoder(this);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
public static class Decoder extends CharsetDecoder {
|
||||
public Decoder(Charset cs) {
|
||||
super(cs, 2.0f, 2.0f);
|
||||
}
|
||||
|
||||
char[] c1 = new char[1];
|
||||
char[] c2 = new char[2];
|
||||
public char[] toUnicode(int b1, int b2, int p) {
|
||||
return decode(b1, b2, p, c1, c2);
|
||||
}
|
||||
|
||||
static final String[] b2c = EUC_TWMapping.b2c;
|
||||
static final int b1Min = EUC_TWMapping.b1Min;
|
||||
static final int b1Max = EUC_TWMapping.b1Max;
|
||||
static final int b2Min = EUC_TWMapping.b2Min;
|
||||
static final int b2Max = EUC_TWMapping.b2Max;
|
||||
static final int dbSegSize = b2Max - b2Min + 1;
|
||||
static final byte[] b2cIsSupp;
|
||||
|
||||
// adjust from cns planeNo to the plane index of b2c
|
||||
static final byte[] cnspToIndex = new byte[0x100];
|
||||
static {
|
||||
Arrays.fill(cnspToIndex, (byte)-1);
|
||||
cnspToIndex[0xa2] = 1; cnspToIndex[0xa3] = 2; cnspToIndex[0xa4] = 3;
|
||||
cnspToIndex[0xa5] = 4; cnspToIndex[0xa6] = 5; cnspToIndex[0xa7] = 6;
|
||||
cnspToIndex[0xaf] = 7;
|
||||
}
|
||||
|
||||
//static final BitSet b2cIsSupp;
|
||||
static {
|
||||
String b2cIsSuppStr = EUC_TWMapping.b2cIsSuppStr;
|
||||
// work on a local copy is much faster than operate
|
||||
// directly on b2cIsSupp
|
||||
byte[] flag = new byte[b2cIsSuppStr.length() << 1];
|
||||
int off = 0;
|
||||
for (int i = 0; i < b2cIsSuppStr.length(); i++) {
|
||||
char c = b2cIsSuppStr.charAt(i);
|
||||
flag[off++] = (byte)(c >> 8);
|
||||
flag[off++] = (byte)(c & 0xff);
|
||||
}
|
||||
b2cIsSupp = flag;
|
||||
}
|
||||
|
||||
static boolean isLegalDB(int b) {
|
||||
return b >= b1Min && b <= b1Max;
|
||||
}
|
||||
|
||||
static char[] decode(int b1, int b2, int p, char[] c1, char[] c2)
|
||||
{
|
||||
if (b1 < b1Min || b1 > b1Max || b2 < b2Min || b2 > b2Max)
|
||||
return null;
|
||||
int index = (b1 - b1Min) * dbSegSize + b2 - b2Min;
|
||||
char c = b2c[p].charAt(index);
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
return null;
|
||||
if ((b2cIsSupp[index] & (1 << p)) == 0) {
|
||||
c1[0] = c;
|
||||
return c1;
|
||||
} else {
|
||||
c2[0] = Character.highSurrogate(0x20000 + c);
|
||||
c2[1] = Character.lowSurrogate(0x20000 + c);
|
||||
return c2;
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult decodeArrayLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
try {
|
||||
while (sp < sl) {
|
||||
int byte1 = sa[sp] & 0xff;
|
||||
if (byte1 == SS2) { // Codeset 2 G2
|
||||
if ( sl - sp < 4)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int cnsPlane = cnspToIndex[sa[sp + 1] & 0xff];
|
||||
if (cnsPlane < 0)
|
||||
return CoderResult.malformedForLength(2);
|
||||
byte1 = sa[sp + 2] & 0xff;
|
||||
int byte2 = sa[sp + 3] & 0xff;
|
||||
char[] cc = toUnicode(byte1, byte2, cnsPlane);
|
||||
if (cc == null) {
|
||||
if (!isLegalDB(byte1) || !isLegalDB(byte2))
|
||||
return CoderResult.malformedForLength(4);
|
||||
return CoderResult.unmappableForLength(4);
|
||||
}
|
||||
if (dl - dp < cc.length)
|
||||
return CoderResult.OVERFLOW;
|
||||
if (cc.length == 1) {
|
||||
da[dp++] = cc[0];
|
||||
} else {
|
||||
da[dp++] = cc[0];
|
||||
da[dp++] = cc[1];
|
||||
}
|
||||
sp += 4;
|
||||
} else if (byte1 < 0x80) { // ASCII G0
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (char) byte1;
|
||||
sp++;
|
||||
} else { // Codeset 1 G1
|
||||
if ( sl - sp < 2)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int byte2 = sa[sp + 1] & 0xff;
|
||||
char[] cc = toUnicode(byte1, byte2, 0);
|
||||
if (cc == null) {
|
||||
if (!isLegalDB(byte1) || !isLegalDB(byte2))
|
||||
return CoderResult.malformedForLength(1);
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = cc[0];
|
||||
sp += 2;
|
||||
}
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult decodeBufferLoop(ByteBuffer src,
|
||||
CharBuffer dst)
|
||||
{
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
int byte1 = src.get() & 0xff;
|
||||
if (byte1 == SS2) { // Codeset 2 G2
|
||||
if ( src.remaining() < 3)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int cnsPlane = cnspToIndex[src.get() & 0xff];
|
||||
if (cnsPlane < 0)
|
||||
return CoderResult.malformedForLength(2);
|
||||
byte1 = src.get() & 0xff;
|
||||
int byte2 = src.get() & 0xff;
|
||||
char[] cc = toUnicode(byte1, byte2, cnsPlane);
|
||||
if (cc == null) {
|
||||
if (!isLegalDB(byte1) || !isLegalDB(byte2))
|
||||
return CoderResult.malformedForLength(4);
|
||||
return CoderResult.unmappableForLength(4);
|
||||
}
|
||||
if (dst.remaining() < cc.length)
|
||||
return CoderResult.OVERFLOW;
|
||||
if (cc.length == 1) {
|
||||
dst.put(cc[0]);
|
||||
} else {
|
||||
dst.put(cc[0]);
|
||||
dst.put(cc[1]);
|
||||
}
|
||||
mark += 4;
|
||||
} else if (byte1 < 0x80) { // ASCII G0
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((char) byte1);
|
||||
mark++;
|
||||
} else { // Codeset 1 G1
|
||||
if (!src.hasRemaining())
|
||||
return CoderResult.UNDERFLOW;
|
||||
int byte2 = src.get() & 0xff;
|
||||
char[] cc = toUnicode(byte1, byte2, 0);
|
||||
if (cc == null) {
|
||||
if (!isLegalDB(byte1) || !isLegalDB(byte2))
|
||||
return CoderResult.malformedForLength(1);
|
||||
return CoderResult.unmappableForLength(2);
|
||||
}
|
||||
if (!dst.hasRemaining())
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put(cc[0]);
|
||||
mark +=2;
|
||||
}
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeLoop(ByteBuffer src, CharBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Encoder extends CharsetEncoder {
|
||||
private byte[] bb = new byte[4];
|
||||
|
||||
public Encoder(Charset cs) {
|
||||
super(cs, 4.0f, 4.0f);
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return (c <= '\u007f' || toEUC(c, bb) != -1);
|
||||
}
|
||||
|
||||
public boolean canEncode(CharSequence cs) {
|
||||
int i = 0;
|
||||
while (i < cs.length()) {
|
||||
char c = cs.charAt(i++);
|
||||
if (Character.isHighSurrogate(c)) {
|
||||
if (i == cs.length())
|
||||
return false;
|
||||
char low = cs.charAt(i++);
|
||||
if (!Character.isLowSurrogate(low) || toEUC(c, low, bb) == -1)
|
||||
return false;
|
||||
} else if (!canEncode(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int toEUC(char hi, char low, byte[] bb) {
|
||||
return encode(hi, low, bb);
|
||||
}
|
||||
|
||||
public int toEUC(char c, byte[] bb) {
|
||||
return encode(c, bb);
|
||||
}
|
||||
|
||||
private CoderResult encodeArrayLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
int inSize;
|
||||
int outSize;
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
inSize = 1;
|
||||
if (c < 0x80) { // ASCII
|
||||
bb[0] = (byte)c;
|
||||
outSize = 1;
|
||||
} else {
|
||||
outSize = toEUC(c, bb);
|
||||
if (outSize == -1) {
|
||||
// to check surrogates only after BMP failed
|
||||
// has the benefit of improving the BMP encoding
|
||||
// 10% faster, with the price of the slowdown of
|
||||
// supplementary character encoding. given the use
|
||||
// of supplementary characters is really rare, this
|
||||
// is something worth doing.
|
||||
if (Character.isHighSurrogate(c)) {
|
||||
if ((sp + 1) == sl)
|
||||
return CoderResult.UNDERFLOW;
|
||||
if (!Character.isLowSurrogate(sa[sp + 1]))
|
||||
return CoderResult.malformedForLength(1);
|
||||
outSize = toEUC(c, sa[sp+1], bb);
|
||||
inSize = 2;
|
||||
} else if (Character.isLowSurrogate(c)) {
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (outSize == -1)
|
||||
return CoderResult.unmappableForLength(inSize);
|
||||
if ( dl - dp < outSize)
|
||||
return CoderResult.OVERFLOW;
|
||||
for (int i = 0; i < outSize; i++)
|
||||
da[dp++] = bb[i];
|
||||
sp += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
int outSize;
|
||||
int inSize;
|
||||
int mark = src.position();
|
||||
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
inSize = 1;
|
||||
char c = src.get();
|
||||
if (c < 0x80) { // ASCII
|
||||
outSize = 1;
|
||||
bb[0] = (byte)c;
|
||||
} else {
|
||||
outSize = toEUC(c, bb);
|
||||
if (outSize == -1) {
|
||||
if (Character.isHighSurrogate(c)) {
|
||||
if (!src.hasRemaining())
|
||||
return CoderResult.UNDERFLOW;
|
||||
char c2 = src.get();
|
||||
if (!Character.isLowSurrogate(c2))
|
||||
return CoderResult.malformedForLength(1);
|
||||
outSize = toEUC(c, c2, bb);
|
||||
inSize = 2;
|
||||
} else if (Character.isLowSurrogate(c)) {
|
||||
return CoderResult.malformedForLength(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (outSize == -1)
|
||||
return CoderResult.unmappableForLength(inSize);
|
||||
if (dst.remaining() < outSize)
|
||||
return CoderResult.OVERFLOW;
|
||||
for (int i = 0; i < outSize; i++)
|
||||
dst.put(bb[i]);
|
||||
mark += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst)
|
||||
{
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
static int encode(char hi, char low, byte[] bb) {
|
||||
int c = Character.toCodePoint(hi, low);
|
||||
if ((c & 0xf0000) != 0x20000)
|
||||
return -1;
|
||||
c -= 0x20000;
|
||||
int index = c2bSuppIndex[c >> 8];
|
||||
if (index == UNMAPPABLE_ENCODING)
|
||||
return -1;
|
||||
index = index + (c & 0xff);
|
||||
int db = c2bSupp[index];
|
||||
if (db == UNMAPPABLE_ENCODING)
|
||||
return -1;
|
||||
int p = (c2bPlane[index] >> 4) & 0xf;
|
||||
bb[0] = (byte)SS2;
|
||||
bb[1] = (byte)(0xa0 | p);
|
||||
bb[2] = (byte)(db >> 8);
|
||||
bb[3] = (byte)db;
|
||||
return 4;
|
||||
}
|
||||
|
||||
static int encode(char c, byte[] bb) {
|
||||
int index = c2bIndex[c >> 8];
|
||||
if (index == UNMAPPABLE_ENCODING)
|
||||
return -1;
|
||||
index = index + (c & 0xff);
|
||||
int db = c2b[index];
|
||||
if (db == UNMAPPABLE_ENCODING)
|
||||
return -1;
|
||||
int p = c2bPlane[index] & 0xf;
|
||||
if (p == 0) {
|
||||
bb[0] = (byte)(db >> 8);
|
||||
bb[1] = (byte)db;
|
||||
return 2;
|
||||
} else {
|
||||
bb[0] = (byte)SS2;
|
||||
bb[1] = (byte)(0xa0 | p);
|
||||
bb[2] = (byte)(db >> 8);
|
||||
bb[3] = (byte)db;
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
static final char[] c2b;
|
||||
static final char[] c2bIndex;
|
||||
static final char[] c2bSupp;
|
||||
static final char[] c2bSuppIndex;
|
||||
static final byte[] c2bPlane;
|
||||
static {
|
||||
int b1Min = Decoder.b1Min;
|
||||
int b1Max = Decoder.b1Max;
|
||||
int b2Min = Decoder.b2Min;
|
||||
int b2Max = Decoder.b2Max;
|
||||
int dbSegSize = Decoder.dbSegSize;
|
||||
String[] b2c = Decoder.b2c;
|
||||
byte[] b2cIsSupp = Decoder.b2cIsSupp;
|
||||
|
||||
c2bIndex = EUC_TWMapping.c2bIndex;
|
||||
c2bSuppIndex = EUC_TWMapping.c2bSuppIndex;
|
||||
char[] c2b0 = new char[EUC_TWMapping.C2BSIZE];
|
||||
char[] c2bSupp0 = new char[EUC_TWMapping.C2BSUPPSIZE];
|
||||
byte[] c2bPlane0 = new byte[Math.max(EUC_TWMapping.C2BSIZE,
|
||||
EUC_TWMapping.C2BSUPPSIZE)];
|
||||
|
||||
Arrays.fill(c2b0, (char)UNMAPPABLE_ENCODING);
|
||||
Arrays.fill(c2bSupp0, (char)UNMAPPABLE_ENCODING);
|
||||
|
||||
for (int p = 0; p < b2c.length; p++) {
|
||||
String db = b2c[p];
|
||||
/*
|
||||
adjust the "plane" from 0..7 to 0, 2, 3, 4, 5, 6, 7, 0xf,
|
||||
which helps balance between footprint (to save the plane
|
||||
info in 4 bits) and runtime performance (to require only
|
||||
one operation "0xa0 | plane" to encode the plane byte)
|
||||
*/
|
||||
int plane = p;
|
||||
if (plane == 7)
|
||||
plane = 0xf;
|
||||
else if (plane != 0)
|
||||
plane = p + 1;
|
||||
|
||||
int off = 0;
|
||||
for (int b1 = b1Min; b1 <= b1Max; b1++) {
|
||||
for (int b2 = b2Min; b2 <= b2Max; b2++) {
|
||||
char c = db.charAt(off);
|
||||
if (c != UNMAPPABLE_DECODING) {
|
||||
if ((b2cIsSupp[off] & (1 << p)) != 0) {
|
||||
int index = c2bSuppIndex[c >> 8] + (c&0xff);
|
||||
c2bSupp0[index] = (char)((b1 << 8) + b2);
|
||||
c2bPlane0[index] |= (byte)(plane << 4);
|
||||
} else {
|
||||
int index = c2bIndex[c >> 8] + (c&0xff);
|
||||
c2b0[index] = (char)((b1 << 8) + b2);
|
||||
c2bPlane0[index] |= (byte)plane;
|
||||
}
|
||||
}
|
||||
off++;
|
||||
}
|
||||
}
|
||||
}
|
||||
c2b = c2b0;
|
||||
c2bSupp = c2bSupp0;
|
||||
c2bPlane = c2bPlane0;
|
||||
}
|
||||
}
|
||||
}
|
||||
10075
jdkSrc/jdk8/sun/nio/cs/ext/EUC_TWMapping.java
Normal file
10075
jdkSrc/jdk8/sun/nio/cs/ext/EUC_TWMapping.java
Normal file
File diff suppressed because it is too large
Load Diff
1353
jdkSrc/jdk8/sun/nio/cs/ext/ExtendedCharsets.java
Normal file
1353
jdkSrc/jdk8/sun/nio/cs/ext/ExtendedCharsets.java
Normal file
File diff suppressed because it is too large
Load Diff
12858
jdkSrc/jdk8/sun/nio/cs/ext/GB18030.java
Normal file
12858
jdkSrc/jdk8/sun/nio/cs/ext/GB18030.java
Normal file
File diff suppressed because it is too large
Load Diff
3291
jdkSrc/jdk8/sun/nio/cs/ext/GBK.java
Normal file
3291
jdkSrc/jdk8/sun/nio/cs/ext/GBK.java
Normal file
File diff suppressed because it is too large
Load Diff
432
jdkSrc/jdk8/sun/nio/cs/ext/HKSCS.java
Normal file
432
jdkSrc/jdk8/sun/nio/cs/ext/HKSCS.java
Normal file
@@ -0,0 +1,432 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.Arrays;
|
||||
import sun.nio.cs.Surrogate;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class HKSCS {
|
||||
|
||||
public static class Decoder extends DoubleByte.Decoder {
|
||||
static int b2Min = 0x40;
|
||||
static int b2Max = 0xfe;
|
||||
|
||||
private char[][] b2cBmp;
|
||||
private char[][] b2cSupp;
|
||||
private DoubleByte.Decoder big5Dec;
|
||||
|
||||
protected Decoder(Charset cs,
|
||||
DoubleByte.Decoder big5Dec,
|
||||
char[][] b2cBmp, char[][] b2cSupp)
|
||||
{
|
||||
// super(cs, 0.5f, 1.0f);
|
||||
// need to extends DoubleByte.Decoder so the
|
||||
// sun.io can use it. this implementation
|
||||
super(cs, 0.5f, 1.0f, null, null, 0, 0);
|
||||
this.big5Dec = big5Dec;
|
||||
this.b2cBmp = b2cBmp;
|
||||
this.b2cSupp = b2cSupp;
|
||||
}
|
||||
|
||||
public char decodeSingle(int b) {
|
||||
return big5Dec.decodeSingle(b);
|
||||
}
|
||||
|
||||
public char decodeBig5(int b1, int b2) {
|
||||
return big5Dec.decodeDouble(b1, b2);
|
||||
}
|
||||
|
||||
public char decodeDouble(int b1, int b2) {
|
||||
return b2cBmp[b1][b2 - b2Min];
|
||||
}
|
||||
|
||||
public char decodeDoubleEx(int b1, int b2) {
|
||||
/* if the b2cSupp is null, the subclass need
|
||||
to override the methold
|
||||
if (b2cSupp == null)
|
||||
return UNMAPPABLE_DECODING;
|
||||
*/
|
||||
return b2cSupp[b1][b2 - b2Min];
|
||||
}
|
||||
|
||||
protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
|
||||
byte[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
char[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
int b1 = sa[sp] & 0xff;
|
||||
char c = decodeSingle(b1);
|
||||
int inSize = 1, outSize = 1;
|
||||
char[] cc = null;
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
if (sl - sp < 2)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int b2 = sa[sp + 1] & 0xff;
|
||||
inSize++;
|
||||
if (b2 < b2Min || b2 > b2Max)
|
||||
return CoderResult.unmappableForLength(2);
|
||||
c = decodeDouble(b1, b2); //bmp
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
c = decodeDoubleEx(b1, b2); //supp
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
c = decodeBig5(b1, b2); //big5
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
return CoderResult.unmappableForLength(2);
|
||||
} else {
|
||||
// supplementary character in u+2xxxx area
|
||||
outSize = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dl - dp < outSize)
|
||||
return CoderResult.OVERFLOW;
|
||||
if (outSize == 2) {
|
||||
// supplementary characters
|
||||
da[dp++] = Surrogate.high(0x20000 + c);
|
||||
da[dp++] = Surrogate.low(0x20000 + c);
|
||||
} else {
|
||||
da[dp++] = c;
|
||||
}
|
||||
sp += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
char[] cc = null;
|
||||
int b1 = src.get() & 0xff;
|
||||
int inSize = 1, outSize = 1;
|
||||
char c = decodeSingle(b1);
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
if (src.remaining() < 1)
|
||||
return CoderResult.UNDERFLOW;
|
||||
int b2 = src.get() & 0xff;
|
||||
inSize++;
|
||||
if (b2 < b2Min || b2 > b2Max)
|
||||
return CoderResult.unmappableForLength(2);
|
||||
c = decodeDouble(b1, b2); //bmp
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
c = decodeDoubleEx(b1, b2); //supp
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
c = decodeBig5(b1, b2); //big5
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
return CoderResult.unmappableForLength(2);
|
||||
} else {
|
||||
outSize = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dst.remaining() < outSize)
|
||||
return CoderResult.OVERFLOW;
|
||||
if (outSize == 2) {
|
||||
dst.put(Surrogate.high(0x20000 + c));
|
||||
dst.put(Surrogate.low(0x20000 + c));
|
||||
} else {
|
||||
dst.put(c);
|
||||
}
|
||||
mark += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
public int decode(byte[] src, int sp, int len, char[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
char repl = replacement().charAt(0);
|
||||
while (sp < sl) {
|
||||
int b1 = src[sp++] & 0xff;
|
||||
char c = decodeSingle(b1);
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
if (sl == sp) {
|
||||
c = repl;
|
||||
} else {
|
||||
int b2 = src[sp++] & 0xff;
|
||||
if (b2 < b2Min || b2 > b2Max) {
|
||||
c = repl;
|
||||
} else if ((c = decodeDouble(b1, b2)) == UNMAPPABLE_DECODING) {
|
||||
c = decodeDoubleEx(b1, b2); //supp
|
||||
if (c == UNMAPPABLE_DECODING) {
|
||||
c = decodeBig5(b1, b2); //big5
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
c = repl;
|
||||
} else {
|
||||
// supplementary character in u+2xxxx area
|
||||
dst[dp++] = Surrogate.high(0x20000 + c);
|
||||
dst[dp++] = Surrogate.low(0x20000 + c);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dst[dp++] = c;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
|
||||
public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return decodeArrayLoop(src, dst);
|
||||
else
|
||||
return decodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
static void initb2c(char[][]b2c, String[] b2cStr)
|
||||
{
|
||||
for (int i = 0; i < b2cStr.length; i++) {
|
||||
if (b2cStr[i] == null)
|
||||
b2c[i] = DoubleByte.B2C_UNMAPPABLE;
|
||||
else
|
||||
b2c[i] = b2cStr[i].toCharArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Encoder extends DoubleByte.Encoder {
|
||||
private DoubleByte.Encoder big5Enc;
|
||||
private char[][] c2bBmp;
|
||||
private char[][] c2bSupp;
|
||||
|
||||
protected Encoder(Charset cs,
|
||||
DoubleByte.Encoder big5Enc,
|
||||
char[][] c2bBmp,
|
||||
char[][] c2bSupp)
|
||||
{
|
||||
super(cs, null, null);
|
||||
this.big5Enc = big5Enc;
|
||||
this.c2bBmp = c2bBmp;
|
||||
this.c2bSupp = c2bSupp;
|
||||
}
|
||||
|
||||
public int encodeBig5(char ch) {
|
||||
return big5Enc.encodeChar(ch);
|
||||
}
|
||||
|
||||
public int encodeChar(char ch) {
|
||||
int bb = c2bBmp[ch >> 8][ch & 0xff];
|
||||
if (bb == UNMAPPABLE_ENCODING)
|
||||
return encodeBig5(ch);
|
||||
return bb;
|
||||
}
|
||||
|
||||
public int encodeSupp(int cp) {
|
||||
if ((cp & 0xf0000) != 0x20000)
|
||||
return UNMAPPABLE_ENCODING;
|
||||
return c2bSupp[(cp >> 8) & 0xff][cp & 0xff];
|
||||
}
|
||||
|
||||
public boolean canEncode(char c) {
|
||||
return encodeChar(c) != UNMAPPABLE_ENCODING;
|
||||
}
|
||||
|
||||
protected CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
int inSize = 1;
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
int cp;
|
||||
if ((cp = sgp().parse(c, sa, sp, sl)) < 0)
|
||||
return sgp.error();
|
||||
bb = encodeSupp(cp);
|
||||
if (bb == UNMAPPABLE_ENCODING)
|
||||
return CoderResult.unmappableForLength(2);
|
||||
inSize = 2;
|
||||
} else {
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
}
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
if (dl - dp < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte)(bb >> 8);
|
||||
da[dp++] = (byte)bb;
|
||||
} else { // SingleByte
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
da[dp++] = (byte)bb;
|
||||
}
|
||||
sp += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
|
||||
int mark = src.position();
|
||||
try {
|
||||
while (src.hasRemaining()) {
|
||||
int inSize = 1;
|
||||
char c = src.get();
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (Character.isSurrogate(c)) {
|
||||
int cp;
|
||||
if ((cp = sgp().parse(c, src)) < 0)
|
||||
return sgp.error();
|
||||
bb = encodeSupp(cp);
|
||||
if (bb == UNMAPPABLE_ENCODING)
|
||||
return CoderResult.unmappableForLength(2);
|
||||
inSize = 2;
|
||||
} else {
|
||||
return CoderResult.unmappableForLength(1);
|
||||
}
|
||||
}
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
if (dst.remaining() < 2)
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)(bb >> 8));
|
||||
dst.put((byte)(bb));
|
||||
} else {
|
||||
if (dst.remaining() < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
dst.put((byte)bb);
|
||||
}
|
||||
mark += inSize;
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(mark);
|
||||
}
|
||||
}
|
||||
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
|
||||
if (src.hasArray() && dst.hasArray())
|
||||
return encodeArrayLoop(src, dst);
|
||||
else
|
||||
return encodeBufferLoop(src, dst);
|
||||
}
|
||||
|
||||
private byte[] repl = replacement();
|
||||
protected void implReplaceWith(byte[] newReplacement) {
|
||||
repl = newReplacement;
|
||||
}
|
||||
|
||||
public int encode(char[] src, int sp, int len, byte[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
while (sp < sl) {
|
||||
char c = src[sp++];
|
||||
int bb = encodeChar(c);
|
||||
if (bb == UNMAPPABLE_ENCODING) {
|
||||
if (!Character.isHighSurrogate(c) || sp == sl ||
|
||||
!Character.isLowSurrogate(src[sp]) ||
|
||||
(bb = encodeSupp(Character.toCodePoint(c, src[sp++])))
|
||||
== UNMAPPABLE_ENCODING) {
|
||||
dst[dp++] = repl[0];
|
||||
if (repl.length > 1)
|
||||
dst[dp++] = repl[1];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (bb > MAX_SINGLEBYTE) { // DoubleByte
|
||||
dst[dp++] = (byte)(bb >> 8);
|
||||
dst[dp++] = (byte)bb;
|
||||
} else { // SingleByte
|
||||
dst[dp++] = (byte)bb;
|
||||
}
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
|
||||
|
||||
static char[] C2B_UNMAPPABLE = new char[0x100];
|
||||
static {
|
||||
Arrays.fill(C2B_UNMAPPABLE, (char)UNMAPPABLE_ENCODING);
|
||||
}
|
||||
|
||||
static void initc2b(char[][] c2b, String[] b2cStr, String pua) {
|
||||
// init c2b/c2bSupp from b2cStr and supp
|
||||
int b2Min = 0x40;
|
||||
Arrays.fill(c2b, C2B_UNMAPPABLE);
|
||||
for (int b1 = 0; b1 < 0x100; b1++) {
|
||||
String s = b2cStr[b1];
|
||||
if (s == null)
|
||||
continue;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
int hi = c >> 8;
|
||||
if (c2b[hi] == C2B_UNMAPPABLE) {
|
||||
c2b[hi] = new char[0x100];
|
||||
Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING);
|
||||
}
|
||||
c2b[hi][c & 0xff] = (char)((b1 << 8) | (i + b2Min));
|
||||
}
|
||||
}
|
||||
if (pua != null) { // add the compatibility pua entries
|
||||
char c = '\ue000'; //first pua character
|
||||
for (int i = 0; i < pua.length(); i++) {
|
||||
char bb = pua.charAt(i);
|
||||
if (bb != UNMAPPABLE_DECODING) {
|
||||
int hi = c >> 8;
|
||||
if (c2b[hi] == C2B_UNMAPPABLE) {
|
||||
c2b[hi] = new char[0x100];
|
||||
Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING);
|
||||
}
|
||||
c2b[hi][c & 0xff] = bb;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2855
jdkSrc/jdk8/sun/nio/cs/ext/HKSCS2001Mapping.java
Normal file
2855
jdkSrc/jdk8/sun/nio/cs/ext/HKSCS2001Mapping.java
Normal file
File diff suppressed because it is too large
Load Diff
2901
jdkSrc/jdk8/sun/nio/cs/ext/HKSCSMapping.java
Normal file
2901
jdkSrc/jdk8/sun/nio/cs/ext/HKSCSMapping.java
Normal file
File diff suppressed because it is too large
Load Diff
1054
jdkSrc/jdk8/sun/nio/cs/ext/HKSCS_XPMapping.java
Normal file
1054
jdkSrc/jdk8/sun/nio/cs/ext/HKSCS_XPMapping.java
Normal file
File diff suppressed because it is too large
Load Diff
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM037.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM037.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM037 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM037() {
|
||||
super("IBM037", ExtendedCharsets.aliasesFor("IBM037"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp037";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM037);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u00A4" + // 0x98 - 0x9f
|
||||
"\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u005E\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u005B\u005D\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u00A2\u002E\u003C\u0028\u002B\u007C" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u0021\u0024\u002A\u0029\u003B\u00AC" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x100];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[165] = UNMAPPABLE_DECODING;
|
||||
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1006.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1006.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1006 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1006() {
|
||||
super("x-IBM1006", ExtendedCharsets.aliasesFor("x-IBM1006"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1006";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1006);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6" + // 0xa0 - 0xa7
|
||||
"\u06F7\u06F8\u06F9\u060C\u061B\u00AD\u061F\uFE81" + // 0xa8 - 0xaf
|
||||
"\uFE8D\uFE8E\uF8FB\uFE8F\uFE91\uFB56\uFB58\uFE93" + // 0xb0 - 0xb7
|
||||
"\uFE95\uFE97\uFB66\uFB68\uFE99\uFE9B\uFE9D\uFE9F" + // 0xb8 - 0xbf
|
||||
"\uFB7A\uFB7C\uFEA1\uFEA3\uFEA5\uFEA7\uFEA9\uFB88" + // 0xc0 - 0xc7
|
||||
"\uFEAB\uFEAD\uFB8C\uFEAF\uFB8A\uFEB1\uFEB3\uFEB5" + // 0xc8 - 0xcf
|
||||
"\uFEB7\uFEB9\uFEBB\uFEBD\uFEBF\uFEC3\uFEC7\uFEC9" + // 0xd0 - 0xd7
|
||||
"\uFECA\uFECB\uFECC\uFECD\uFECE\uFECF\uFED0\uFED1" + // 0xd8 - 0xdf
|
||||
"\uFED3\uFED5\uFED7\uFB8E\uFEDB\uFB92\uFB94\uFEDD" + // 0xe0 - 0xe7
|
||||
"\uFEDF\uFEE0\uFEE1\uFEE3\uFB9E\uFEE5\uFEE7\uFE85" + // 0xe8 - 0xef
|
||||
"\uFEED\uFBA6\uFBA8\uFBA9\uFBAA\uFE80\uFE89\uFE8A" + // 0xf0 - 0xf7
|
||||
"\uFE8B\uFBFC\uFBFD\uFBFE\uFBB0\uFBAE\uFE7C\uFE7D" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1025.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1025.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1025 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1025() {
|
||||
super("x-IBM1025", ExtendedCharsets.aliasesFor("x-IBM1025"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1025";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1025);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0446\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u0434\u0435\u0444\u0433\u0445\u0438" + // 0x88 - 0x8f
|
||||
"\u0439\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u043A\u043B\u043C\u043D\u043E\u043F" + // 0x98 - 0x9f
|
||||
"\u044F\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u0440\u0441\u0442\u0443\u0436\u0432" + // 0xa8 - 0xaf
|
||||
"\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A" + // 0xb0 - 0xb7
|
||||
"\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u0425\u0418\u0419\u041A\u041B\u041C" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u041D\u041E\u041F\u042F\u0420\u0421" + // 0xd8 - 0xdf
|
||||
"\\\u00A7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u0422\u0423\u0416\u0412\u042C\u042B" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u0417\u0428\u042D\u0429\u0427\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u0452\u0453\u0451\u0454\u0455\u0456" + // 0x40 - 0x47
|
||||
"\u0457\u0458\u005B\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u0459\u045A\u045B\u045C\u045E\u045F\u042A" + // 0x50 - 0x57
|
||||
"\u2116\u0402\u005D\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u0403\u0401\u0404\u0405\u0406\u0407" + // 0x60 - 0x67
|
||||
"\u0408\u0409\u007C\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u040A\u040B\u040C\u00AD\u040E\u040F\u044E\u0430" + // 0x70 - 0x77
|
||||
"\u0431\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[165] = UNMAPPABLE_DECODING;
|
||||
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1026.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1026.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1026 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1026() {
|
||||
super("IBM1026", ExtendedCharsets.aliasesFor("IBM1026"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1026";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1026);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u007D\u0060\u00A6\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u00A4" + // 0x98 - 0x9f
|
||||
"\u00B5\u00F6\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u005D\u0024\u0040\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00E7\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u007E\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u011F\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\\\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\u00FC\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u0023\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\"\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u007B\u00F1\u00C7\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u011E\u0130\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u005B\u00D1\u015F\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0131\u003A\u00D6\u015E\'\u003D\u00DC" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[165] = UNMAPPABLE_DECODING;
|
||||
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1046.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1046.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1046 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1046() {
|
||||
super("x-IBM1046", ExtendedCharsets.aliasesFor("x-IBM1046"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1046";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1046);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\uFE88\u00D7\u00F7\uF8F6\uF8F5\uF8F4\uF8F7\uFE71" + // 0x80 - 0x87
|
||||
"\u0088\u25A0\u2502\u2500\u2510\u250C\u2514\u2518" + // 0x88 - 0x8f
|
||||
"\uFE79\uFE7B\uFE7D\uFE7F\uFE77\uFE8A\uFEF0\uFEF3" + // 0x90 - 0x97
|
||||
"\uFEF2\uFECE\uFECF\uFED0\uFEF6\uFEF8\uFEFA\uFEFC" + // 0x98 - 0x9f
|
||||
"\u00A0\uF8FA\uF8F9\uF8F8\u00A4\uF8FB\uFE8B\uFE91" + // 0xa0 - 0xa7
|
||||
"\uFE97\uFE9B\uFE9F\uFEA3\u060C\u00AD\uFEA7\uFEB3" + // 0xa8 - 0xaf
|
||||
"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667" + // 0xb0 - 0xb7
|
||||
"\u0668\u0669\uFEB7\u061B\uFEBB\uFEBF\uFECA\u061F" + // 0xb8 - 0xbf
|
||||
"\uFECB\uFE80\uFE81\uFE83\uFE85\uFE87\uFE89\uFE8D" + // 0xc0 - 0xc7
|
||||
"\uFE8F\uFE93\uFE95\uFE99\uFE9D\uFEA1\uFEA5\uFEA9" + // 0xc8 - 0xcf
|
||||
"\uFEAB\uFEAD\uFEAF\uFEB1\uFEB5\uFEB9\uFEBD\uFEC3" + // 0xd0 - 0xd7
|
||||
"\uFEC7\uFEC9\uFECD\uFECC\uFE82\uFE84\uFE8E\uFED3" + // 0xd8 - 0xdf
|
||||
"\u0640\uFED1\uFED5\uFED9\uFEDD\uFEE1\uFEE5\uFEEB" + // 0xe0 - 0xe7
|
||||
"\uFEED\uFEEF\uFEF1\uFE70\uFE72\uFE74\uFE76\uFE78" + // 0xe8 - 0xef
|
||||
"\uFE7A\uFE7C\uFE7E\uFED7\uFEDB\uFEDF\uF8FC\uFEF5" + // 0xf0 - 0xf7
|
||||
"\uFEF7\uFEF9\uFEFB\uFEE3\uFEE7\uFEEC\uFEE9\uFFFD" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x600];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1047.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1047.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1047 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1047() {
|
||||
super("IBM1047", ExtendedCharsets.aliasesFor("IBM1047"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1047";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1047);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u00A4" + // 0x98 - 0x9f
|
||||
"\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u005B\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00AC\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00DD\u00A8\u00AF\u005D\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u00A2\u002E\u003C\u0028\u002B\u007C" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u0021\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x100];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1097.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1097.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1097 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1097() {
|
||||
super("x-IBM1097", ExtendedCharsets.aliasesFor("x-IBM1097"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1097";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1097);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\uFB8A\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\uFEB1\uFEB3\uFEB5\uFEB7" + // 0x88 - 0x8f
|
||||
"\uFEB9\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\uFEBB\uFEBD\uFEBF\uFEC1\uFEC3\uFEC5" + // 0x98 - 0x9f
|
||||
"\uFEC7\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\uFEC9\uFECA\uFECB\uFECC\uFECD\uFECE" + // 0xa8 - 0xaf
|
||||
"\uFECF\uFED0\uFED1\uFED3\uFED5\uFED7\uFB8E\uFEDB" + // 0xb0 - 0xb7
|
||||
"\uFB92\uFB94\u005B\u005D\uFEDD\uFEDF\uFEE1\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\uFEE3\uFEE5\uFEE7\uFEED\uFEE9" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\uFEEB\uFEEC\uFBA4\uFBFC\uFBFD\uFBFE" + // 0xd8 - 0xdf
|
||||
"\\\u061F\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u0640\u06F0\u06F1\u06F2\u06F3\u06F4" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u06F5\u06F6\u06F7\u06F8\u06F9\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\u0085\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u060C\u064B\uFE81\uFE82\uF8FA\uFE8D" + // 0x40 - 0x47
|
||||
"\uFE8E\uF8FB\u00A4\u002E\u003C\u0028\u002B\u007C" + // 0x48 - 0x4f
|
||||
"\u0026\uFE80\uFE83\uFE84\uF8F9\uFE85\uFE8B\uFE8F" + // 0x50 - 0x57
|
||||
"\uFE91\uFB56\u0021\u0024\u002A\u0029\u003B\u00AC" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\uFB58\uFE95\uFE97\uFE99\uFE9B\uFE9D" + // 0x60 - 0x67
|
||||
"\uFE9F\uFB7A\u061B\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\uFB7C\uFEA1\uFEA3\uFEA5\uFEA7\uFEA9\uFEAB\uFEAD" + // 0x70 - 0x77
|
||||
"\uFEAF\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x500];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1098.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1098.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1098 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1098() {
|
||||
super("x-IBM1098", ExtendedCharsets.aliasesFor("x-IBM1098"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1098";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1098);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\uFFFD\uFFFD\u060C\u061B\u061F\u064B\uFE81\uFE82" + // 0x80 - 0x87
|
||||
"\uF8FA\uFE8D\uFE8E\uF8FB\uFE80\uFE83\uFE84\uF8F9" + // 0x88 - 0x8f
|
||||
"\uFE85\uFE8B\uFE8F\uFE91\uFB56\uFB58\uFE95\uFE97" + // 0x90 - 0x97
|
||||
"\uFE99\uFE9B\uFE9D\uFE9F\uFB7A\uFB7C\u00D7\uFEA1" + // 0x98 - 0x9f
|
||||
"\uFEA3\uFEA5\uFEA7\uFEA9\uFEAB\uFEAD\uFEAF\uFB8A" + // 0xa0 - 0xa7
|
||||
"\uFEB1\uFEB3\uFEB5\uFEB7\uFEB9\uFEBB\u00AB\u00BB" + // 0xa8 - 0xaf
|
||||
"\u2591\u2592\u2593\u2502\u2524\uFEBD\uFEBF\uFEC1" + // 0xb0 - 0xb7
|
||||
"\uFEC3\u2563\u2551\u2557\u255D\u00A4\uFEC5\u2510" + // 0xb8 - 0xbf
|
||||
"\u2514\u2534\u252C\u251C\u2500\u253C\uFEC7\uFEC9" + // 0xc0 - 0xc7
|
||||
"\u255A\u2554\u2569\u2566\u2560\u2550\u256C\uFFFD" + // 0xc8 - 0xcf
|
||||
"\uFECA\uFECB\uFECC\uFECD\uFECE\uFECF\uFED0\uFED1" + // 0xd0 - 0xd7
|
||||
"\uFED3\u2518\u250C\u2588\u2584\uFED5\uFED7\u2580" + // 0xd8 - 0xdf
|
||||
"\uFB8E\uFEDB\uFB92\uFB94\uFEDD\uFEDF\uFEE1\uFEE3" + // 0xe0 - 0xe7
|
||||
"\uFEE5\uFEE7\uFEED\uFEE9\uFEEB\uFEEC\uFBA4\uFBFC" + // 0xe8 - 0xef
|
||||
"\u00AD\uFBFD\uFBFE\u0640\u06F0\u06F1\u06F2\u06F3" + // 0xf0 - 0xf7
|
||||
"\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9\u25A0\u00A0" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x700];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1112.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1112.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1112 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1112() {
|
||||
super("x-IBM1112", ExtendedCharsets.aliasesFor("x-IBM1112"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1112";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1112);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u0101\u017C\u0144\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u0156\u0157\u00E6\u0137\u00C6\u00A4" + // 0x98 - 0x9f
|
||||
"\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u201D\u017A\u0100\u017B\u0143\u00AE" + // 0xa8 - 0xaf
|
||||
"\u005E\u00A3\u012B\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u005B\u005D\u0179\u0136\u013C\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u014D\u00F6\u0146\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u0107\u00FC\u0142\u015B\u2019" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u014C\u00D6\u0145\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u0106\u00DC\u0141\u015A\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u0161\u00E4\u0105\u012F\u016B\u00E5" + // 0x40 - 0x47
|
||||
"\u0113\u017E\u00A2\u002E\u003C\u0028\u002B\u007C" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u0119\u0117\u010D\u0173\u201E\u201C" + // 0x50 - 0x57
|
||||
"\u0123\u00DF\u0021\u0024\u002A\u0029\u003B\u00AC" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u0160\u00C4\u0104\u012E\u016A\u00C5" + // 0x60 - 0x67
|
||||
"\u0112\u017D\u00A6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u0118\u0116\u010C\u0172\u012A\u013B" + // 0x70 - 0x77
|
||||
"\u0122\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[165] = UNMAPPABLE_DECODING;
|
||||
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1122.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1122.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1122 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1122() {
|
||||
super("x-IBM1122", ExtendedCharsets.aliasesFor("x-IBM1122"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1122";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1122);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u0161\u00FD\u017E\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u005D" + // 0x98 - 0x9f
|
||||
"\u00B5\u00FC\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u0160\u00DD\u017D\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u005B\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u203E\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00E4\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00A6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u00E5\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u007E\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\u00C9\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u0040\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u007B\u00E0\u00E1\u00E3\u007D" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u00A7\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u0060\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u00A4\u00C5\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u0023\u00C0\u00C1\u00C3\u0024" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00F6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\\\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u00E9\u003A\u00C4\u00D6\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[165] = UNMAPPABLE_DECODING;
|
||||
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1123.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1123.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1123 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1123() {
|
||||
super("x-IBM1123", ExtendedCharsets.aliasesFor("x-IBM1123"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1123";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1123);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0446\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u0434\u0435\u0444\u0433\u0445\u0438" + // 0x88 - 0x8f
|
||||
"\u0439\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u043A\u043B\u043C\u043D\u043E\u043F" + // 0x98 - 0x9f
|
||||
"\u044F\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u0440\u0441\u0442\u0443\u0436\u0432" + // 0xa8 - 0xaf
|
||||
"\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A" + // 0xb0 - 0xb7
|
||||
"\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u0425\u0418\u0419\u041A\u041B\u041C" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u041D\u041E\u041F\u042F\u0420\u0421" + // 0xd8 - 0xdf
|
||||
"\\\u00A7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u0422\u0423\u0416\u0412\u042C\u042B" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u0417\u0428\u042D\u0429\u0427\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u0452\u0491\u0451\u0454\u0455\u0456" + // 0x40 - 0x47
|
||||
"\u0457\u0458\u005B\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u0459\u045A\u045B\u045C\u045E\u045F\u042A" + // 0x50 - 0x57
|
||||
"\u2116\u0402\u005D\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u0490\u0401\u0404\u0405\u0406\u0407" + // 0x60 - 0x67
|
||||
"\u0408\u0409\u007C\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u040A\u040B\u040C\u00AD\u040E\u040F\u044E\u0430" + // 0x70 - 0x77
|
||||
"\u0431\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[165] = UNMAPPABLE_DECODING;
|
||||
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1124.java
Normal file
102
jdkSrc/jdk8/sun/nio/cs/ext/IBM1124.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1124 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1124() {
|
||||
super("x-IBM1124", ExtendedCharsets.aliasesFor("x-IBM1124"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1124";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1124);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
|
||||
"\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8f
|
||||
"\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
|
||||
"\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9f
|
||||
"\u00A0\u0401\u0402\u0490\u0404\u0405\u0406\u0407" + // 0xa0 - 0xa7
|
||||
"\u0408\u0409\u040A\u040B\u040C\u00AD\u040E\u040F" + // 0xa8 - 0xaf
|
||||
"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417" + // 0xb0 - 0xb7
|
||||
"\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F" + // 0xb8 - 0xbf
|
||||
"\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427" + // 0xc0 - 0xc7
|
||||
"\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F" + // 0xc8 - 0xcf
|
||||
"\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437" + // 0xd0 - 0xd7
|
||||
"\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F" + // 0xd8 - 0xdf
|
||||
"\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447" + // 0xe0 - 0xe7
|
||||
"\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F" + // 0xe8 - 0xef
|
||||
"\u2116\u0451\u0452\u0491\u0454\u0455\u0456\u0457" + // 0xf0 - 0xf7
|
||||
"\u0458\u0459\u045A\u045B\u045C\u00A7\u045E\u045F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
|
||||
"\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
|
||||
"\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2f
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
|
||||
"\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3f
|
||||
"\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
|
||||
"\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4f
|
||||
"\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
|
||||
"\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5f
|
||||
"\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
|
||||
"\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6f
|
||||
"\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
|
||||
"\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x300];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1140.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1140.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1140 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1140() {
|
||||
super("IBM01140", ExtendedCharsets.aliasesFor("IBM01140"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1140";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1140);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC" + // 0x98 - 0x9f
|
||||
"\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u005E\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u005B\u005D\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u00A2\u002E\u003C\u0028\u002B\u007C" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u0021\u0024\u002A\u0029\u003B\u00AC" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1141.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1141.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1141 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1141() {
|
||||
super("IBM01141", ExtendedCharsets.aliasesFor("IBM01141"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1141";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1141);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC" + // 0x98 - 0x9f
|
||||
"\u00B5\u00DF\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u0040\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00E4\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00A6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u00FC\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u007D\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\u00D6\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\\\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u005D\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u007B\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u00C4\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u007E\u00DC\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u005B\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00F6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u0023\u00A7\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1142.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1142.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1142 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1142() {
|
||||
super("IBM01142", ExtendedCharsets.aliasesFor("IBM01142"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1142";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1142);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0040\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u007B\u00B8\u005B\u005D" + // 0x98 - 0x9f
|
||||
"\u00B5\u00FC\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00E6\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u00E5\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u007E\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u007D" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u0023\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u20AC\u00C5\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u0024" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00F8\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00A6\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u00C6\u00D8\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1143.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1143.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1143 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1143() {
|
||||
super("IBM01143", ExtendedCharsets.aliasesFor("IBM01143"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1143";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1143);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u005D" + // 0x98 - 0x9f
|
||||
"\u00B5\u00FC\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u005B\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00E4\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00A6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u00E5\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u007E\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\u00C9\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u0040\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u007B\u00E0\u00E1\u00E3\u007D" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u00A7\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u0060\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u20AC\u00C5\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u0023\u00C0\u00C1\u00C3\u0024" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00F6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\\\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u00E9\u003A\u00C4\u00D6\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1144.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1144.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1144 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1144() {
|
||||
super("IBM01144", ExtendedCharsets.aliasesFor("IBM01144"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1144";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1144);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u005B\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC" + // 0x98 - 0x9f
|
||||
"\u00B5\u00EC\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u0023\u00A5\u00B7\u00A9\u0040\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00E0\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00A6\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u00E8\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u0060\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\u00E7\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u007B\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\\\u00F1\u00B0\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u005D\u00EA\u00EB\u007D\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u007E\u00DF\u00E9\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00F2\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u00F9\u003A\u00A3\u00A7\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1145.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1145.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1145 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1145() {
|
||||
super("IBM01145", ExtendedCharsets.aliasesFor("IBM01145"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1145";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1145);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC" + // 0x98 - 0x9f
|
||||
"\u00B5\u00A8\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u005E\u0021\u00AF\u007E\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00A6\u005B\u002E\u003C\u0028\u002B\u007C" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u005D\u0024\u002A\u0029\u003B\u00AC" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u0023\u00F1\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u00D1\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1146.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1146.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1146 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1146() {
|
||||
super("IBM01146", ExtendedCharsets.aliasesFor("IBM01146"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1146";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1146);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC" + // 0x98 - 0x9f
|
||||
"\u00B5\u00AF\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u005B\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u005E\u005D\u007E\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u0024\u002E\u003C\u0028\u002B\u007C" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u0021\u00A3\u002A\u0029\u003B\u00AC" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1147.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1147.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1147 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1147() {
|
||||
super("IBM01147", ExtendedCharsets.aliasesFor("IBM01147"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1147";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1147);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u005B\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC" + // 0x98 - 0x9f
|
||||
"\u0060\u00A8\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u0023\u00A5\u00B7\u00A9\u005D\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u007E\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00E9\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u00E8\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00A6\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\u00E7\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u0040\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\\\u00F1\u00B0\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u007B\u00EA\u00EB\u007D\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u00A7\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00F9\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u00B5\u003A\u00A3\u00E0\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1148.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1148.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1148 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1148() {
|
||||
super("IBM01148", ExtendedCharsets.aliasesFor("IBM01148"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1148";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1148);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC" + // 0x98 - 0x9f
|
||||
"\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\\\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u005B\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u005D\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1149.java
Normal file
106
jdkSrc/jdk8/sun/nio/cs/ext/IBM1149.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1149 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1149() {
|
||||
super("IBM01149", ExtendedCharsets.aliasesFor("IBM01149"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1149";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1149);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u00AB\u00BB\u0060\u00FD\u007B\u00B1" + // 0x88 - 0x8f
|
||||
"\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u00AA\u00BA\u007D\u00B8\u005D\u20AC" + // 0x98 - 0x9f
|
||||
"\u00B5\u00F6\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u00A1\u00BF\u0040\u00DD\u005B\u00AE" + // 0xa8 - 0xaf
|
||||
"\u00A2\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC" + // 0xb0 - 0xb7
|
||||
"\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\\\u00D7" + // 0xb8 - 0xbf
|
||||
"\u00FE\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u00AD\u00F4\u007E\u00F2\u00F3\u00F5" + // 0xc8 - 0xcf
|
||||
"\u00E6\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF" + // 0xd8 - 0xdf
|
||||
"\u00B4\u00F7\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u00B2\u00D4\u005E\u00D2\u00D3\u00D5" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5" + // 0x40 - 0x47
|
||||
"\u00E7\u00F1\u00DE\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF" + // 0x50 - 0x57
|
||||
"\u00EC\u00DF\u00C6\u0024\u002A\u0029\u003B\u00D6" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5" + // 0x60 - 0x67
|
||||
"\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF" + // 0x70 - 0x77
|
||||
"\u00CC\u00F0\u003A\u0023\u00D0\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x200];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1166.java
Normal file
110
jdkSrc/jdk8/sun/nio/cs/ext/IBM1166.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.cs.ext;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.SingleByte;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class IBM1166 extends Charset implements HistoricallyNamedCharset
|
||||
{
|
||||
public IBM1166() {
|
||||
super("x-IBM1166", ExtendedCharsets.aliasesFor("x-IBM1166"));
|
||||
}
|
||||
|
||||
public String historicalName() {
|
||||
return "Cp1166";
|
||||
}
|
||||
|
||||
public boolean contains(Charset cs) {
|
||||
return (cs instanceof IBM1166);
|
||||
}
|
||||
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new SingleByte.Decoder(this, b2c);
|
||||
}
|
||||
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new SingleByte.Encoder(this, c2b, c2bIndex);
|
||||
}
|
||||
|
||||
private final static String b2cTable =
|
||||
"\u0446\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x80 - 0x87
|
||||
"\u0068\u0069\u0434\u0435\u0444\u0433\u0445\u0438" + // 0x88 - 0x8f
|
||||
"\u0439\u006A\u006B\u006C\u006D\u006E\u006F\u0070" + // 0x90 - 0x97
|
||||
"\u0071\u0072\u043A\u043B\u043C\u043D\u043E\u043F" + // 0x98 - 0x9f
|
||||
"\u044F\u007E\u0073\u0074\u0075\u0076\u0077\u0078" + // 0xa0 - 0xa7
|
||||
"\u0079\u007A\u0440\u0441\u0442\u0443\u0436\u0432" + // 0xa8 - 0xaf
|
||||
"\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A" + // 0xb0 - 0xb7
|
||||
"\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413" + // 0xb8 - 0xbf
|
||||
"\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0xc0 - 0xc7
|
||||
"\u0048\u0049\u0425\u0418\u0419\u041A\u041B\u041C" + // 0xc8 - 0xcf
|
||||
"\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050" + // 0xd0 - 0xd7
|
||||
"\u0051\u0052\u041D\u041E\u041F\u042F\u0420\u0421" + // 0xd8 - 0xdf
|
||||
"\\\u20AC\u0053\u0054\u0055\u0056\u0057\u0058" + // 0xe0 - 0xe7
|
||||
"\u0059\u005A\u0422\u0423\u0416\u0412\u042C\u042B" + // 0xe8 - 0xef
|
||||
"\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0xf0 - 0xf7
|
||||
"\u0038\u0039\u0417\u0428\u042D\u0429\u0427\u009F" + // 0xf8 - 0xff
|
||||
"\u0000\u0001\u0002\u0003\u009C\t\u0086\u007F" + // 0x00 - 0x07
|
||||
"\u0097\u008D\u008E\u000B\f\r\u000E\u000F" + // 0x08 - 0x0f
|
||||
"\u0010\u0011\u0012\u0013\u009D\n\b\u0087" + // 0x10 - 0x17
|
||||
"\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F" + // 0x18 - 0x1f
|
||||
"\u0080\u0081\u0082\u0083\u0084\n\u0017\u001B" + // 0x20 - 0x27
|
||||
"\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007" + // 0x28 - 0x2f
|
||||
"\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004" + // 0x30 - 0x37
|
||||
"\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A" + // 0x38 - 0x3f
|
||||
"\u0020\u00A0\u04D9\u0493\u0451\u0454\u0455\u0456" + // 0x40 - 0x47
|
||||
"\u049B\u0458\u005B\u002E\u003C\u0028\u002B\u0021" + // 0x48 - 0x4f
|
||||
"\u0026\u04A3\u04E9\u04B1\u04AF\u045E\u04BB\u042A" + // 0x50 - 0x57
|
||||
"\u2116\u04D8\u005D\u0024\u002A\u0029\u003B\u005E" + // 0x58 - 0x5f
|
||||
"\u002D\u002F\u0492\u0401\u0404\u0405\u0406\u049A" + // 0x60 - 0x67
|
||||
"\u0408\u04A2\u007C\u002C\u0025\u005F\u003E\u003F" + // 0x68 - 0x6f
|
||||
"\u04E8\u04B0\u04AE\u00AD\u040E\u04BA\u044E\u0430" + // 0x70 - 0x77
|
||||
"\u0431\u0060\u003A\u0023\u0040\'\u003D\"" ; // 0x78 - 0x7f
|
||||
|
||||
|
||||
private final static char[] b2c = b2cTable.toCharArray();
|
||||
private final static char[] c2b = new char[0x400];
|
||||
private final static char[] c2bIndex = new char[0x100];
|
||||
|
||||
static {
|
||||
char[] b2cMap = b2c;
|
||||
char[] c2bNR = null;
|
||||
// remove non-roundtrip entries
|
||||
b2cMap = b2cTable.toCharArray();
|
||||
b2cMap[165] = UNMAPPABLE_DECODING;
|
||||
|
||||
// non-roundtrip c2b only entries
|
||||
c2bNR = new char[2];
|
||||
c2bNR[0] = 0x15; c2bNR[1] = 0x85;
|
||||
|
||||
SingleByte.initC2B(b2cMap, c2bNR, c2b, c2bIndex);
|
||||
}
|
||||
}
|
||||
3478
jdkSrc/jdk8/sun/nio/cs/ext/IBM1364.java
Normal file
3478
jdkSrc/jdk8/sun/nio/cs/ext/IBM1364.java
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user