@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;
		}

		// test for numeric encodings
		Character second = input.next();
		if (second == null) {
			input.reset();
			return null;
		}

		if (second == '#') {
			// handle numbers
			Character c = getNumericEntity(input);
			if (c != null) {
				return c;
			}
		} else if (Character.isLetter(second.charValue())) {
			// handle entities
			input.pushback(second);
			Character c = getNamedEntity(input);
			if (c != null) {
				return c;
			}
		}
		input.reset();
		return null;
	}