int getNextUtf8Byte(int pos, int count) throws java.lang.Exception
    {
        int val;

        // Take a character from the buffer
        // or from the actual input stream.
        if (pos < count) {
            val = rawReadBuffer[pos];
        } else {
            val = is.read();
            if (val == -1) {
                encodingError("unfinished multi-byte UTF-8 sequence at EOF",
                        -1, pos);
            }
        }

        // Check for the correct bits at the
        // start.
        if ((val & 0xc0) != 0x80) {
            encodingError("bad continuation of multi-byte UTF-8 sequence", val,
                    pos + 1);
        }

        // Return the significant bits.
        return (val & 0x3f);
    }