@Override
	public Character decodeCharacter(final PushbackString input) {
		input.mark();
		Character first = input.next();
		if (first == null) {
			input.reset();
			return null;
		}

		// if this is not an encoded character, return null
		if (first != '%') {
			input.reset();
			return null;
		}

		// Search for exactly 2 hex digits following
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 2; i++) {
			Character c = input.nextHex();
			if (c != null) {
				sb.append(c);
			}
		}
		if (sb.length() == 2) {
			try {
				// parse the hex digit and create a character
				int i = Integer.parseInt(sb.toString(), 16);
				if (Character.isValidCodePoint(i)) {
					return (char) i;
				}
			} catch (NumberFormatException ignored) {
			}
		}
		input.reset();
		return null;
	}