home *** CD-ROM | disk | FTP | other *** search
Wrap
package sun.io; public abstract class CharToByteEUC extends CharToByteConverter { private char highHalfZoneCode; private byte[] outputByte; protected short[] index1; protected String index2; protected String index2a; protected String index2b; protected String index2c; protected int mask1; protected int mask2; protected int shift; private byte[] workByte = new byte[4]; public int flush(byte[] var1, int var2, int var3) throws MalformedInputException, ConversionBufferFullException { if (this.highHalfZoneCode != 0) { this.reset(); super.badInputLength = 0; throw new MalformedInputException(); } else { this.reset(); return 0; } } public int convert(char[] var1, int var2, int var3, byte[] var4, int var5, int var6) throws UnknownCharacterException, MalformedInputException, ConversionBufferFullException { super.byteOff = var5; int var8; for(super.charOff = var2; super.charOff < var3; super.charOff += var8) { this.outputByte = this.workByte; boolean var11 = true; char var7; if (this.highHalfZoneCode == 0) { var7 = var1[super.charOff]; var8 = 1; } else { var7 = this.highHalfZoneCode; var8 = 0; this.highHalfZoneCode = 0; } if (var7 >= '\ud800' && var7 <= '\udbff') { if (super.charOff + var8 >= var3) { this.highHalfZoneCode = var7; super.charOff += var8; break; } var7 = var1[super.charOff + var8]; if (var7 < '\udc00' || var7 > '\udfff') { super.badInputLength = 1; throw new MalformedInputException(); } if (!super.subMode) { super.badInputLength = 2; throw new UnknownCharacterException(); } this.outputByte = super.subBytes; ++var8; } else { if (var7 >= '\udc00' && var7 <= '\udfff') { super.badInputLength = 1; throw new MalformedInputException(); } int var9 = this.index1[(var7 & this.mask1) >> this.shift] + (var7 & this.mask2); String var13; if (var9 < 7500) { var13 = this.index2; } else if (var9 < 15000) { var9 -= 7500; var13 = this.index2a; } else if (var9 < 22500) { var9 -= 15000; var13 = this.index2b; } else { var9 -= 22500; var13 = this.index2c; } char var14 = var13.charAt(2 * var9); this.outputByte[0] = (byte)((var14 & '\uff00') >> 8); this.outputByte[1] = (byte)(var14 & 255); var14 = var13.charAt(2 * var9 + 1); this.outputByte[2] = (byte)((var14 & '\uff00') >> 8); this.outputByte[3] = (byte)(var14 & 255); } for(int var12 = 0; var12 < this.outputByte.length; ++var12) { if (this.outputByte[var12] != 0) { var11 = false; break; } } if (var11 && var7 != 0) { if (!super.subMode) { super.badInputLength = 1; throw new UnknownCharacterException(); } this.outputByte = super.subBytes; } int var16 = 0; int var10; for(var10 = this.outputByte.length; var10 > 1 && this.outputByte[var16++] == 0; --var10) { } if (super.byteOff + var10 > var6) { throw new ConversionBufferFullException(); } for(int var15 = this.outputByte.length - var10; var15 < this.outputByte.length; ++var15) { var4[super.byteOff++] = this.outputByte[var15]; } } return super.byteOff - var5; } public void reset() { super.charOff = super.byteOff = 0; this.highHalfZoneCode = 0; } public int getMaxBytesPerChar() { return 2; } public boolean canConvert(char var1) { int var2 = this.index1[(var1 & this.mask1) >> this.shift] + (var1 & this.mask2); String var3; if (var2 < 7500) { var3 = this.index2; } else if (var2 < 15000) { var2 -= 7500; var3 = this.index2a; } else if (var2 < 22500) { var2 -= 15000; var3 = this.index2b; } else { var2 -= 22500; var3 = this.index2c; } if (var3.charAt(2 * var2) == 0 && var3.charAt(2 * var2 + 1) == 0) { return var1 == 0; } else { return true; } } }