private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
	int mark = src.position();
	try {
	    while (src.hasRemaining()) {
		char c = src.get();
		if (Surrogate.is(c)) {
		    if (sgp.parse(c, src) < 0)
			return sgp.error();
		    return sgp.unmappableResult();
		}
		if (c >= '\uFFFE')
		    return CoderResult.unmappableForLength(1);
		if (!dst.hasRemaining())
		    return CoderResult.OVERFLOW;

		char e = index2.charAt(index1[(c & mask1) >> shift]
				       + (c & mask2));

		// If output byte is zero because input char is zero
		// then character is mappable, o.w. fail
		if (e == '\u0000' && c != '\u0000')
		    return CoderResult.unmappableForLength(1);

		mark++;
		dst.put((byte)e);
	    }
	    return CoderResult.UNDERFLOW;
	} finally {
	    src.position(mark);
	}
    }