Rewrite of IBM doublebyte charsets (original) (raw)
Ulf Zibis Ulf.Zibis at gmx.de
Tue May 12 18:25:15 UTC 2009
- Previous message: Rewrite of IBM doublebyte charsets
- Next message: Rewrite of IBM doublebyte charsets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sherman, thanks for verifying my suggestions.
(1) simplify the "plane number" byte check by adding a new static array of cnspToIndex[16] for decoder What you think about:
int cnsPlane = sa[sp +1] ^ 0xa0;
if (cnsPlane > 0xf ||
(cnsPlane = cnspToIndex[cnsPlane]) < 0)
return CoderResult.malformedForLength(2);
or maybe (to force LoadUB, which may be faster than sign extension to int): int cnsPlane = (sa[sp +1] ^ 0xa0) && 0xff;
or maybe use byte[] (to force LoadUB, which may be faster than sign extension to int): byte cnsPlane = (byte)(sa[sp +1] ^ 0xa0);
or simply:
static final byte[] cnspToIndex = new byte[0x100];
static {
Arrays.fill(cnspToIndex, -1);
cnspToIndex[0xa2] = 1; cnspToIndex[0xa3] = 2;
cnspToIndex[0xa4] = 3; cnspToIndex[0xa5] = 4; cnspToIndex[0xa6] = 5; cnspToIndex[0xa7] = 6; cnspToIndex[0xaf] = 7; }
if ((cnsPlane = cnspToIndex[sa[sp + 1] && 0xff]) < 0)
return CoderResult.malformedForLength(2);
*** Question: Why you code:
} else if ((byte1 & MSB) == 0) { // ASCII G0
instead of:
} else if (byte1 >= 0) { // ASCII G0
???
-Ulf
- Previous message: Rewrite of IBM doublebyte charsets
- Next message: Rewrite of IBM doublebyte charsets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]