private int getEncodedCharLength()

in src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java [134:148]


    private int getEncodedCharLength(final int current) throws CharacterCodingException {
        final char cChar = (char) current;
        final char lChar = (char) lastChar;
        if (!Character.isSurrogate(cChar)) {
            return encoder.encode(CharBuffer.wrap(new char[] { cChar })).limit();
        }
        if (Character.isHighSurrogate(cChar)) {
            // Move on to the next char (low surrogate)
            return 0;
        } else if (Character.isSurrogatePair(lChar, cChar)) {
            return encoder.encode(CharBuffer.wrap(new char[] { lChar, cChar })).limit();
        } else {
            throw new CharacterCodingException();
        }
    }