mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8275863: Use encodeASCII for ASCII-compatible DoubleByte encodings
Reviewed-by: naoto, rriggs, alanb
This commit is contained in:
parent
2f979ecb5b
commit
6c05cc9d15
5 changed files with 31 additions and 11 deletions
|
@ -111,11 +111,11 @@ public class DoubleByte {
|
|||
Arrays.fill(B2C_UNMAPPABLE, UNMAPPABLE_DECODING);
|
||||
}
|
||||
|
||||
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
|
||||
|
||||
public static class Decoder extends CharsetDecoder
|
||||
implements DelegatableDecoder, ArrayDecoder
|
||||
{
|
||||
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
|
||||
|
||||
final char[][] b2c;
|
||||
final char[] b2cSB;
|
||||
final int b2Min;
|
||||
|
@ -601,6 +601,11 @@ public class DoubleByte {
|
|||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
try {
|
||||
if (isASCIICompatible) {
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
}
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
int bb = encodeChar(c);
|
||||
|
@ -681,7 +686,11 @@ public class DoubleByte {
|
|||
public int encode(char[] src, int sp, int len, byte[] dst) {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
int dl = dst.length;
|
||||
if (isASCIICompatible) {
|
||||
int n = JLA.encodeASCII(src, sp, dst, dp, len);
|
||||
sp += n;
|
||||
dp += n;
|
||||
}
|
||||
while (sp < sl) {
|
||||
char c = src[sp++];
|
||||
int bb = encodeChar(c);
|
||||
|
|
|
@ -42,9 +42,9 @@ public class HKSCS {
|
|||
static int b2Min = 0x40;
|
||||
static int b2Max = 0xfe;
|
||||
|
||||
private char[][] b2cBmp;
|
||||
private char[][] b2cSupp;
|
||||
private DoubleByte.Decoder big5Dec;
|
||||
private final char[][] b2cBmp;
|
||||
private final char[][] b2cSupp;
|
||||
private final DoubleByte.Decoder big5Dec;
|
||||
|
||||
protected Decoder(Charset cs,
|
||||
DoubleByte.Decoder big5Dec,
|
||||
|
@ -94,7 +94,6 @@ public class HKSCS {
|
|||
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;
|
||||
|
@ -137,7 +136,6 @@ public class HKSCS {
|
|||
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);
|
||||
|
@ -230,9 +228,9 @@ public class HKSCS {
|
|||
}
|
||||
|
||||
public static class Encoder extends DoubleByte.Encoder {
|
||||
private DoubleByte.Encoder big5Enc;
|
||||
private char[][] c2bBmp;
|
||||
private char[][] c2bSupp;
|
||||
private final DoubleByte.Encoder big5Enc;
|
||||
private final char[][] c2bBmp;
|
||||
private final char[][] c2bSupp;
|
||||
|
||||
protected Encoder(Charset cs,
|
||||
DoubleByte.Encoder big5Enc,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue