val = val | ((temp & 0x3f) << (i * 6));
val = val | ((temp & 0x3f) << ((i<<2)+(i<<1)));
	private int getChar()		throws EncodingException, EOFException, ParseException {		int temp = 0;		int a = 0, c = 0, d = 0, val = 0;		if (offset >= endOffset)			throw new EOFException("permature EOF reached, XML document incomplete");		switch (encoding) {			case FORMAT_ASCII :				temp = XMLDoc[offset];				offset++;				return temp;			case FORMAT_UTF8 :				temp = XMLDoc[offset];				if (temp >= 0) {					offset++;					return temp;				}				temp = temp & 0xff;				switch (UTF8Char.byteCount(temp)) { // handle multi-byte code					case 2 :						c = 0x1f;						// A mask determine the val portion of the first byte						d = 6; // 						a = 1; //						break;					case 3 :						c = 0x0f;						d = 12;						a = 2;						break;					case 4 :						c = 0x07;						d = 18;						a = 3;						break;					case 5 :						c = 0x03;						d = 24;						a = 4;						break;					case 6 :						c = 0x01;						d = 30;						a = 5;						break;					default :						throw new ParseException("UTF 8 encoding error: should never happen");				}				val = (temp & c) << d;				int i = a - 1;				while (i >= 0) {					temp = XMLDoc[offset + a - i];					if ((temp & 0xc0) != 0x80)						throw new ParseException("UTF 8 encoding error: should never happen");					val = val | ((temp & 0x3f) << (i * 6));					i--;				}				offset += a + 1;				return val;			case FORMAT_UTF_16BE :				// implement UTF-16BE to UCS4 conversion				temp = XMLDoc[offset] << 8 | XMLDoc[offset + 1];				if ((temp < 0xd800)					|| (temp >= 0xdc00)) { // not a high surrogate					offset += 2;					return temp;				} else {					val = temp;					temp = XMLDoc[offset + 2] << 8 | XMLDoc[offset + 3];					if (temp < 0xdc00 | temp > 0xdfff) {						// has to be a low surrogate here						throw new EncodingException("UTF 16 BE encoding error: should never happen");					}					//val = (val - 0xd800) * 0x400 + (temp - 0xdc00) + 0x10000;					val = ((temp - 0xd800) <<10) + (val - 0xdc00) + 0x10000;					offset += 4;					return val;				}			case FORMAT_UTF_16LE :				temp = XMLDoc[offset + 1] << 8 | XMLDoc[offset];				if (temp < 0xdc00 || temp > 0xdfff) { // check for low surrogate					offset += 2;					return temp;				} else {					val = temp;					temp = XMLDoc[offset + 3] << 8 | XMLDoc[offset + 2];					if (temp < 0xd800 | temp > 0xdc00) {						// has to be high surrogate						throw new EncodingException("UTF 16 LE encoding error: should never happen");					}					//val = (temp - 0xd800) * 0x400 + (val - 0xdc00) + 0x10000;					val = ((temp - 0xd800)<<10) + (val - 0xdc00) + 0x10000;					offset += 4;					return val;				}			case FORMAT_ISO_8859 :				temp = XMLDoc[offset];				offset++;				return temp & 0xff;			default :				throw new EncodingException("Unknown encoding");		}	}