@@ -62,6 +62,9 @@ public class RebufferableBinaryReader
6262 /// </summary>
6363 private readonly BinaryStreamStack streamStack ;
6464
65+ /// <summary>
66+ /// The BOM (AKA preamble) for the encoding.
67+ /// </summary>
6568 private readonly byte [ ] preamble ;
6669
6770 #endregion
@@ -290,7 +293,7 @@ public string ReadLine()
290293 byte [ ] data = ReadByteLine ( ) ;
291294
292295 if ( data == null ) return null ;
293- else if ( StartsWith ( data , preamble ) ) return encoding . GetString ( data . Skip ( preamble . Length ) . ToArray ( ) ) ;
296+ else if ( data . StartsWith ( preamble ) ) return encoding . GetString ( data . Skip ( preamble . Length ) . ToArray ( ) ) ;
294297 else return encoding . GetString ( data ) ;
295298 }
296299
@@ -456,33 +459,14 @@ public async Task<string> ReadLineAsync(CancellationToken cancellationToken = de
456459 byte [ ] data = await ReadByteLineAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
457460
458461 if ( data == null ) return null ;
459- else if ( StartsWith ( data , preamble ) ) return encoding . GetString ( data . Skip ( preamble . Length ) . ToArray ( ) ) ;
462+ else if ( data . StartsWith ( preamble ) ) return encoding . GetString ( data . Skip ( preamble . Length ) . ToArray ( ) ) ;
460463 else return encoding . GetString ( data ) ;
461464 }
462465
463466 #endregion
464467
465468 #region Methods
466469
467- /// <summary>
468- /// Determines if the source byte array starts with the specified pattern.
469- /// </summary>
470- /// <param name="src">The source byte array.</param>
471- /// <param name="pattern">The pattern.</param>
472- /// <returns>True if the source byte array starts with the specified pattern, false otherwise.</returns>
473- private static bool StartsWith ( byte [ ] src , byte [ ] pattern )
474- {
475- if ( src == null || pattern == null ) return false ;
476- if ( src . Length < pattern . Length ) return false ;
477-
478- for ( int i = 0 ; i < pattern . Length - 1 ; i ++ )
479- {
480- if ( src [ i ] != pattern [ i ] ) return false ;
481- }
482-
483- return true ;
484- }
485-
486470 /// <summary>
487471 /// Reads more data from the stream into the stream stack.
488472 /// </summary>
0 commit comments