*/
public static void decode(final BufferChunk srcBufferChunk,
final ByteChunk dstByteChunk,
final boolean allowEncodedSlash) throws CharConversionException {
final Buffer srcBuffer = srcBufferChunk.getBuffer();
final int srcStart = srcBufferChunk.getStart();
final int srcEnd = srcBufferChunk.getEnd();
final byte[] dstBuffer = dstByteChunk.getBuffer();
int idx = dstByteChunk.getStart();
for (int j = srcStart; j < srcEnd; j++, idx++) {
final byte b = srcBuffer.get(j);
if (b == '+') {
dstBuffer[idx] = (byte) ' ';
} else if (b != '%') {
dstBuffer[idx] = b;
} else {
// read next 2 digits
if (j + 2 >= srcEnd) {
throw new IllegalStateException("Unexpected termination");
}
byte b1 = srcBuffer.get(j + 1);
byte b2 = srcBuffer.get(j + 2);
if (!HexUtils.isHexDigit(b1) || !HexUtils.isHexDigit(b2)) {
throw new IllegalArgumentException(
"URLDecoder: Illegal hex characters in escape (%) pattern - %"
+ (char) b1 + "" + (char) b2);