@@ -32,19 +32,12 @@ final class Lexer implements Closeable {
3232 private static final String CR_STRING = Character .toString (Constants .CR );
3333 private static final String LF_STRING = Character .toString (Constants .LF );
3434
35- /**
36- * Constant char to use for disabling comments, escapes, and encapsulation. The value -2 is used because it
37- * won't be confused with an EOF signal (-1), and because the Unicode value {@code FFFE} would be encoded as two
38- * chars (using surrogates) and thus there should never be a collision with a real text char.
39- */
40- private static final char DISABLED = '\ufffe' ;
41-
4235 private final char [] delimiter ;
4336 private final char [] delimiterBuf ;
4437 private final char [] escapeDelimiterBuf ;
45- private final char escape ;
46- private final char quoteChar ;
47- private final char commentStart ;
38+ private final int escape ;
39+ private final int quoteChar ;
40+ private final int commentStart ;
4841 private final boolean ignoreSurroundingSpaces ;
4942 private final boolean ignoreEmptyLines ;
5043 private final boolean lenientEof ;
@@ -59,9 +52,9 @@ final class Lexer implements Closeable {
5952 Lexer (final CSVFormat format , final ExtendedBufferedReader reader ) {
6053 this .reader = reader ;
6154 this .delimiter = format .getDelimiterCharArray ();
62- this .escape = mapNullToDisabled (format .getEscapeCharacter ());
63- this .quoteChar = mapNullToDisabled (format .getQuoteCharacter ());
64- this .commentStart = mapNullToDisabled (format .getCommentMarker ());
55+ this .escape = nullToDisabled (format .getEscapeCharacter ());
56+ this .quoteChar = nullToDisabled (format .getQuoteCharacter ());
57+ this .commentStart = nullToDisabled (format .getCommentMarker ());
6558 this .ignoreSurroundingSpaces = format .getIgnoreSurroundingSpaces ();
6659 this .ignoreEmptyLines = format .getIgnoreEmptyLines ();
6760 this .lenientEof = format .getLenientEof ();
@@ -197,8 +190,8 @@ boolean isStartOfLine(final int ch) {
197190 return ch == Constants .LF || ch == Constants .CR || ch == Constants .UNDEFINED ;
198191 }
199192
200- private char mapNullToDisabled (final Character c ) {
201- return c == null ? DISABLED : c .charValue (); // N.B. Explicit (un)boxing is intentional
193+ private int nullToDisabled (final Character c ) {
194+ return c == null ? Constants . UNDEFINED : c .charValue (); // Explicit unboxing
202195 }
203196
204197 /**
@@ -428,7 +421,7 @@ private void appendNextEscapedCharacterToToken(final Token token) throws IOExcep
428421 } else {
429422 final int unescaped = readEscape ();
430423 if (unescaped == EOF ) { // unexpected char after escape
431- token .content .append (escape ).append ((char ) reader .getLastChar ());
424+ token .content .append (( char ) escape ).append ((char ) reader .getLastChar ());
432425 } else {
433426 token .content .append ((char ) unescaped );
434427 }
0 commit comments