34 import java.util.regex.Pattern; |
34 import java.util.regex.Pattern; |
35 import java.util.*; |
35 import java.util.*; |
36 import java.security.*; |
36 import java.security.*; |
37 |
37 |
38 public class CharsetMapping { |
38 public class CharsetMapping { |
39 public final static char UNMAPPABLE_DECODING = '\uFFFD'; |
39 public static final char UNMAPPABLE_DECODING = '\uFFFD'; |
40 public final static int UNMAPPABLE_ENCODING = 0xFFFD; |
40 public static final int UNMAPPABLE_ENCODING = 0xFFFD; |
41 |
41 |
42 char[] b2cSB; //singlebyte b->c |
42 char[] b2cSB; //singlebyte b->c |
43 char[] b2cDB1; //dobulebyte b->c /db1 |
43 char[] b2cDB1; //dobulebyte b->c /db1 |
44 char[] b2cDB2; //dobulebyte b->c /db2 |
44 char[] b2cDB2; //dobulebyte b->c /db2 |
45 |
45 |
193 return Arrays.binarySearch(a, 0, a.length, k, comparatorComp); |
193 return Arrays.binarySearch(a, 0, a.length, k, comparatorComp); |
194 } |
194 } |
195 |
195 |
196 /*****************************************************************************/ |
196 /*****************************************************************************/ |
197 // tags of different charset mapping tables |
197 // tags of different charset mapping tables |
198 private final static int MAP_SINGLEBYTE = 0x1; // 0..256 : c |
198 private static final int MAP_SINGLEBYTE = 0x1; // 0..256 : c |
199 private final static int MAP_DOUBLEBYTE1 = 0x2; // min..max: c |
199 private static final int MAP_DOUBLEBYTE1 = 0x2; // min..max: c |
200 private final static int MAP_DOUBLEBYTE2 = 0x3; // min..max: c [DB2] |
200 private static final int MAP_DOUBLEBYTE2 = 0x3; // min..max: c [DB2] |
201 private final static int MAP_SUPPLEMENT = 0x5; // db,c |
201 private static final int MAP_SUPPLEMENT = 0x5; // db,c |
202 private final static int MAP_SUPPLEMENT_C2B = 0x6; // c,db |
202 private static final int MAP_SUPPLEMENT_C2B = 0x6; // c,db |
203 private final static int MAP_COMPOSITE = 0x7; // db,base,cc |
203 private static final int MAP_COMPOSITE = 0x7; // db,base,cc |
204 private final static int MAP_INDEXC2B = 0x8; // index table of c->bb |
204 private static final int MAP_INDEXC2B = 0x8; // index table of c->bb |
205 |
205 |
206 private static final boolean readNBytes(InputStream in, byte[] bb, int N) |
206 private static final boolean readNBytes(InputStream in, byte[] bb, int N) |
207 throws IOException |
207 throws IOException |
208 { |
208 { |
209 int off = 0; |
209 int off = 0; |