while (i < count) { b1 = rawReadBuffer[i++];
    private void copyUtf8ReadBuffer (int count)    throws SAXException, IOException    {	int	i = 0;	int	j = readBufferPos;	int	b1;	char	c = 0;	/*	// check once, so the runtime won't (if it's smart enough)	if (count < 0 || count > rawReadBuffer.length)	    throw new ArrayIndexOutOfBoundsException (Integer.toString (count));	*/	while (i < count) {	    b1 = rawReadBuffer [i++];	    // Determine whether we are dealing	    // with a one-, two-, three-, or four-	    // byte sequence.	    if (b1 < 0) {		if ((b1 & 0xe0) == 0xc0) {		    // 2-byte sequence: 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx		    c = (char) (((b1 & 0x1f) << 6)				| getNextUtf8Byte (i++, count));		    if (c < 0x0080)			encodingError ("Illegal two byte UTF-8 sequence",				c, 0);		    //Sec 2.11		    // [1] the two-character sequence #xD #xA		    // [2] the two-character sequence #xD #x85		    if ((c == 0x0085 || c == 0x000a) && sawCR)		       	continue;		    		    // Sec 2.11		    // [3] the single character #x85		    		    if(c == 0x0085  && xmlVersion == XML_11)		    	readBuffer[j++] = '\r';		} else if ((b1 & 0xf0) == 0xe0) {		    // 3-byte sequence:		    // zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx		    // most CJKV characters		    c = (char) (((b1 & 0x0f) << 12) |				   (getNextUtf8Byte (i++, count) << 6) |				   getNextUtf8Byte (i++, count));                    //sec 2.11		    //[4] the single character #x2028		    if(c == 0x2028 && xmlVersion == XML_11){		       	readBuffer[j++] = '\r';		       	sawCR = true;		       	continue;		    }		    if (c < 0x0800 || (c >= 0xd800 && c <= 0xdfff))			encodingError ("Illegal three byte UTF-8 sequence",				c, 0);		} else if ((b1 & 0xf8) == 0xf0) {		    // 4-byte sequence: 11101110wwwwzzzzyy + 110111yyyyxxxxxx		    //     = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx		    // (uuuuu = wwww + 1)		    // "Surrogate Pairs" ... from the "Astral Planes"		    // Unicode 3.1 assigned the first characters there		    int iso646 = b1 & 07;		    iso646 = (iso646 << 6) + getNextUtf8Byte (i++, count);		    iso646 = (iso646 << 6) + getNextUtf8Byte (i++, count);		    iso646 = (iso646 << 6) + getNextUtf8Byte (i++, count);		    if (iso646 <= 0xffff) {			encodingError ("Illegal four byte UTF-8 sequence",				iso646, 0);		    } else {			if (iso646 > 0x0010ffff)			    encodingError (				"UTF-8 value out of range for Unicode",				iso646, 0);			iso646 -= 0x010000;			readBuffer [j++] = (char) (0xd800 | (iso646 >> 10));			readBuffer [j++] = (char) (0xdc00 | (iso646 & 0x03ff));			continue;		    }		} else {		    // The five and six byte encodings aren't supported;		    // they exceed the Unicode (and XML) range.		    encodingError (			    "unsupported five or six byte UTF-8 sequence",			    0xff & b1, i);		    // NOTREACHED		    c = 0;		}	    } else {		// 1-byte sequence: 000000000xxxxxxx = 0xxxxxxx		// (US-ASCII character, "common" case, one branch to here)		c = (char) b1;	    }	    readBuffer [j++] = c;	    if (c == '\r')		sawCR = true;	}	// How many characters have we read?	readBufferLength = j;    }