src/java.base/share/classes/sun/nio/cs/DoubleByte.java
Print this page
*** 21,31 ****
* 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;
--- 21,31 ----
* 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;
*** 128,148 ****
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();
--- 128,148 ----
return CoderResult.malformedForLength(1);
}
return CoderResult.unmappableForLength(2);
}
! public 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;
}
! public 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();
*** 271,281 ****
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() {
--- 271,281 ----
private static final int DBCS = 1;
private static final int SO = 0x0e;
private static final int SI = 0x0f;
private int currentState;
! public Decoder_EBCDIC(Charset cs,
char[][] b2c, char[] b2cSB, int b2Min, int b2Max) {
super(cs, b2c, b2cSB, b2Min, b2Max);
}
public void implReset() {
*** 449,459 ****
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
--- 449,459 ----
static final char[] b2cSB_UNMAPPABLE;
static {
b2cSB_UNMAPPABLE = new char[0x100];
Arrays.fill(b2cSB_UNMAPPABLE, UNMAPPABLE_DECODING);
}
! public 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
*** 461,471 ****
// 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
--- 461,471 ----
// return "malformed" if found
public static class Decoder_EUC_SIM extends Decoder {
private final int SS2 = 0x8E;
private final int SS3 = 0x8F;
! public 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
*** 509,540 ****
}
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;
}
--- 509,540 ----
}
public static class Encoder extends CharsetEncoder
implements ArrayEncoder
{
! protected final int MAX_SINGLEBYTE = 0xff;
private final char[] c2b;
private final char[] c2bIndex;
! protected Surrogate.Parser sgp;
! public Encoder(Charset cs, char[] c2b, char[] c2bIndex) {
super(cs, 2.0f, 2.0f);
this.c2b = c2b;
this.c2bIndex = c2bIndex;
}
! public 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;
}
! protected Surrogate.Parser sgp() {
if (sgp == null)
sgp = new Surrogate.Parser();
return sgp;
}
*** 655,665 ****
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;
--- 655,665 ----
public int encodeChar(char ch) {
return c2b[c2bIndex[ch >> 8] + (ch & 0xff)];
}
// init the c2b and c2bIndex tables from b2c.
! public 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;
*** 739,749 ****
}
}
}
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) {
--- 739,749 ----
}
}
}
public static class Encoder_DBCSONLY extends Encoder {
! public Encoder_DBCSONLY(Charset cs, byte[] repl,
char[] c2b, char[] c2bIndex) {
super(cs, 2.0f, 2.0f, repl, c2b, c2bIndex);
}
public int encodeChar(char ch) {
*** 762,772 ****
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;
--- 762,772 ----
static final byte SO = 0x0e;
static final byte SI = 0x0f;
protected int currentState = SBCS;
! public 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;
*** 919,929 ****
}
}
// EUC_SIMPLE
public static class Encoder_EUC_SIM extends Encoder {
! Encoder_EUC_SIM(Charset cs, char[] c2b, char[] c2bIndex) {
super(cs, c2b, c2bIndex);
}
}
}
--- 919,929 ----
}
}
// EUC_SIMPLE
public static class Encoder_EUC_SIM extends Encoder {
! public Encoder_EUC_SIM(Charset cs, char[] c2b, char[] c2bIndex) {
super(cs, c2b, c2bIndex);
}
}
}