@@ -2148,7 +2148,7 @@ private void printWithEscapes(final CharSequence charSeq, final Appendable appen
21482148 appendable .append (c );
21492149
21502150 if (isDelimiterStart ) {
2151- pos = appendUntilDelimiter (delimLength , pos , charSeq , appendable );
2151+ pos = appendUntilDelimiterGetPosition (delimLength , pos , charSeq , appendable );
21522152 }
21532153
21542154 start = pos + 1 ; // start on the current char after this one
@@ -2162,7 +2162,7 @@ private void printWithEscapes(final CharSequence charSeq, final Appendable appen
21622162 }
21632163 }
21642164
2165- private int appendUntilDelimiter (int delimLength , int pos , CharSequence charSeq , Appendable appendable ) throws IOException {
2165+ private int appendUntilDelimiterGetPosition (int delimLength , int pos , CharSequence charSeq , Appendable appendable ) throws IOException {
21662166 final char escape = getEscapeCharacter ().charValue ();
21672167
21682168 for (int i = 1 ; i < delimLength ; i ++) {
@@ -2175,9 +2175,24 @@ private int appendUntilDelimiter(int delimLength, int pos, CharSequence charSeq,
21752175 return pos ;
21762176 }
21772177
2178+ private void appendUntilDelimiter (ExtendedBufferedReader bufferedReader , Appendable appendable , int delimLength ) throws IOException {
2179+ final char escape = getEscapeCharacter ().charValue ();
2180+
2181+ for (int i = 1 ; i < delimLength ; i ++) {
2182+ int c = bufferedReader .read ();
2183+ append (escape , appendable );
2184+ append ((char ) c , appendable );
2185+ }
2186+
2187+ }
2188+
21782189 private boolean isCRLFEscape (char c ) {
21792190 return c == CR || c == LF || c == getEscapeCharacter ().charValue ();
21802191 }
2192+ // private boolean isCRLFEscape(int x) {
2193+ // char c = (char) x;
2194+ // return c == CR || c == LF || c == getEscapeCharacter().charValue();
2195+ // }
21812196
21822197 private void printWithEscapes (final Reader reader , final Appendable appendable ) throws IOException {
21832198 int start = 0 ;
@@ -2195,7 +2210,7 @@ private void printWithEscapes(final Reader reader, final Appendable appendable)
21952210 builder .append ((char ) c );
21962211 final boolean isDelimiterStart = isDelimiter ((char ) c , builder .toString () + new String (bufferedReader .lookAhead (delimLength - 1 )), pos , delim ,
21972212 delimLength );
2198- if (c == CR || c == LF || c == escape || isDelimiterStart ) {
2213+ if (isCRLFEscape (( char ) c ) || isDelimiterStart ) {
21992214 // write out segment up until this char
22002215 if (pos > start ) {
22012216 append (builder .substring (start , pos ), appendable );
@@ -2212,11 +2227,7 @@ private void printWithEscapes(final Reader reader, final Appendable appendable)
22122227 append ((char ) c , appendable );
22132228
22142229 if (isDelimiterStart ) {
2215- for (int i = 1 ; i < delimLength ; i ++) {
2216- c = bufferedReader .read ();
2217- append (escape , appendable );
2218- append ((char ) c , appendable );
2219- }
2230+ appendUntilDelimiter (bufferedReader , appendable , delimLength );
22202231 }
22212232
22222233 start = pos + 1 ; // start on the current char after this one
0 commit comments