@@ -2236,26 +2236,30 @@ public synchronized void printRecord(final Appendable appendable, final Object..
22362236 * Note: Must only be called if escaping is enabled, otherwise can throw exceptions.
22372237 */
22382238 private void printWithEscapes (final CharSequence charSeq , final Appendable appendable ) throws IOException {
2239- int start = 0 ;
2240- int pos = 0 ;
2241- final int end = charSeq .length ();
2239+
22422240 final char [] delimArray = getDelimiterCharArray ();
22432241 final int delimLength = delimArray .length ;
22442242 final char escape = getEscapeChar ();
2243+
2244+ int start = 0 ;
2245+ int pos = 0 ;
2246+ final int end = charSeq .length ();
2247+
22452248 while (pos < end ) {
22462249 char c = charSeq .charAt (pos );
2247- final boolean isDelimiterStart = isDelimiter ( c , charSeq , pos , delimArray , delimLength );
2250+
22482251 final boolean isCr = c == Constants .CR ;
22492252 final boolean isLf = c == Constants .LF ;
2250- if (isCr || isLf || c == escape || isDelimiterStart ) {
2251- // write out segment up until this char
2253+ if (isDelimiter ( c , charSeq , pos , delimArray , delimLength ) || isCr || isLf || c == escape ) {
2254+ // handle escaped character or delimiter
22522255 if (pos > start ) {
22532256 appendable .append (charSeq , start , pos );
2257+ // write out segment until this char
22542258 }
22552259 if (isLf ) {
2256- c = 'n' ;
2260+ c = 'n' ; // convert isLF to 'n'
22572261 } else if (isCr ) {
2258- c = 'r' ;
2262+ c = 'r' ; // convert isCR to 'r'
22592263 }
22602264 escape (c , appendable );
22612265 if (isDelimiterStart ) {
0 commit comments