8080803: sun/nio/cs/FindEncoderBugs.java failing intermittently
To eliminate an extra byte buffer and copy in iso2022 encoding Reviewed-by: alanb, darcy
This commit is contained in:
parent
d1d75812b0
commit
4612edcf52
@ -395,7 +395,7 @@ abstract class ISO2022
|
||||
|
||||
protected final byte maximumDesignatorLength = 4;
|
||||
|
||||
protected String SODesig,
|
||||
protected byte[] SODesig,
|
||||
SS2Desig = null,
|
||||
SS3Desig = null;
|
||||
|
||||
@ -426,21 +426,18 @@ abstract class ISO2022
|
||||
SS3DesDefined = false;
|
||||
}
|
||||
|
||||
private int unicodeToNative(char unicode, byte ebyte[])
|
||||
{
|
||||
private int unicodeToNative(char unicode, byte ebyte[]) {
|
||||
int index = 0;
|
||||
byte tmpByte[];
|
||||
char convChar[] = {unicode};
|
||||
byte convByte[] = new byte[4];
|
||||
int converted;
|
||||
|
||||
try{
|
||||
CharBuffer cc = CharBuffer.wrap(convChar);
|
||||
ByteBuffer bb = ByteBuffer.allocate(4);
|
||||
ByteBuffer bb = ByteBuffer.wrap(convByte);
|
||||
ISOEncoder.encode(cc, bb, true);
|
||||
bb.flip();
|
||||
converted = bb.remaining();
|
||||
bb.get(convByte,0,converted);
|
||||
} catch(Exception e) {
|
||||
return -1;
|
||||
}
|
||||
@ -449,9 +446,8 @@ abstract class ISO2022
|
||||
if (!SODesDefined) {
|
||||
newSODesDefined = true;
|
||||
ebyte[0] = ISO_ESC;
|
||||
tmpByte = SODesig.getBytes();
|
||||
System.arraycopy(tmpByte,0,ebyte,1,tmpByte.length);
|
||||
index = tmpByte.length+1;
|
||||
System.arraycopy(SODesig, 0, ebyte, 1, SODesig.length);
|
||||
index = SODesig.length + 1;
|
||||
}
|
||||
if (!shiftout) {
|
||||
newshiftout = true;
|
||||
@ -465,9 +461,8 @@ abstract class ISO2022
|
||||
if (!SS2DesDefined) {
|
||||
newSS2DesDefined = true;
|
||||
ebyte[0] = ISO_ESC;
|
||||
tmpByte = SS2Desig.getBytes();
|
||||
System.arraycopy(tmpByte, 0, ebyte, 1, tmpByte.length);
|
||||
index = tmpByte.length+1;
|
||||
System.arraycopy(SS2Desig, 0, ebyte, 1, SS2Desig.length);
|
||||
index = SS2Desig.length + 1;
|
||||
}
|
||||
ebyte[index++] = ISO_ESC;
|
||||
ebyte[index++] = ISO_SS2_7;
|
||||
@ -477,9 +472,8 @@ abstract class ISO2022
|
||||
if(!SS3DesDefined){
|
||||
newSS3DesDefined = true;
|
||||
ebyte[0] = ISO_ESC;
|
||||
tmpByte = SS3Desig.getBytes();
|
||||
System.arraycopy(tmpByte, 0, ebyte, 1, tmpByte.length);
|
||||
index = tmpByte.length+1;
|
||||
System.arraycopy(SS3Desig, 0, ebyte, 1, SS3Desig.length);
|
||||
index = SS3Desig.length + 1;
|
||||
}
|
||||
ebyte[index++] = ISO_ESC;
|
||||
ebyte[index++] = ISO_SS3_7;
|
||||
@ -560,7 +554,6 @@ abstract class ISO2022
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private CoderResult encodeBufferLoop(CharBuffer src,
|
||||
ByteBuffer dst)
|
||||
{
|
||||
|
@ -67,9 +67,9 @@ public class ISO2022_CN_CNS extends ISO2022 implements HistoricallyNamedCharset
|
||||
public Encoder(Charset cs)
|
||||
{
|
||||
super(cs);
|
||||
SODesig = "$)G";
|
||||
SS2Desig = "$*H";
|
||||
SS3Desig = "$+I";
|
||||
SODesig = new byte[] {'$', ')', 'G' };
|
||||
SS2Desig = new byte[] {'$', '*', 'H' };
|
||||
SS3Desig = new byte[] {'$', '+', 'I' };
|
||||
|
||||
try {
|
||||
Charset cset = Charset.forName("EUC_TW"); // CNS11643
|
||||
|
@ -68,7 +68,7 @@ public class ISO2022_CN_GB extends ISO2022 implements HistoricallyNamedCharset
|
||||
public Encoder(Charset cs)
|
||||
{
|
||||
super(cs);
|
||||
SODesig = "$)A";
|
||||
SODesig = new byte[] { '$', ')', 'A'};
|
||||
|
||||
try {
|
||||
Charset cset = Charset.forName("EUC_CN"); // GB2312
|
||||
|
@ -81,11 +81,9 @@ implements HistoricallyNamedCharset
|
||||
|
||||
private static class Encoder extends ISO2022.Encoder {
|
||||
|
||||
public Encoder(Charset cs)
|
||||
{
|
||||
public Encoder(Charset cs) {
|
||||
super(cs);
|
||||
SODesig = "$)C";
|
||||
|
||||
SODesig = new byte[] {'$', ')', 'C' };
|
||||
try {
|
||||
ISOEncoder = ksc5601_cs.newEncoder();
|
||||
} catch (Exception e) { }
|
||||
|
Loading…
Reference in New Issue
Block a user