
For a single byte encoding, every byte is the start (and end) of a characterĬharacterStartDetector = (pos, data) => true Internal ReverseLineReader(Func streamSource, Encoding encoding, int bufferSize)

: this(streamSource, encoding, DefaultBufferSize) Public ReverseLineReader(Func streamSource, Encoding encoding) / Encoding to use to decode the stream into text / called when the enumerator is fetched. : this(() => File.OpenRead(filename), encoding) Public ReverseLineReader(string filename, Encoding encoding) / Encoding to use to decode the file into text Public ReverseLineReader(string filename) / UTF8 is used to decode the file into text. / (or even checked for existence) when the enumerator is fetched. / Creates a LineReader from a filename. Public ReverseLineReader(Func streamSource) / Creates a LineReader from a stream source. / or not the byte represents the start of a character. / Function which, when given a position within a file and a byte, states whether This must be at least as big as the maximum number of / Size of buffer (in bytes) to read each time we read from the / Encoding to use when converting bytes to text / Means of creating a Stream to read from. Private const int DefaultBufferSize = 4096 / a different buffer size - this is useful for testing. Public sealed class ReverseLineReader : IEnumerable

/ returned by the function must be seekable. / Only single byte encodings, and UTF-8 and Unicode, are supported.

/ (or a filename for convenience) and yields lines from the end of the stream backwards. / Takes an encoding (defaulting to UTF-8) and a function which produces a seekable stream Ah, y necesita refactorización, hay un método bastante fuerte, como verán: Utiliza StreamUtil de MiscUtil, pero he incluido el método necesario (nuevo) desde allí en la parte inferior. No hay nada incorporado en el marco, y sospecho que tendrías que hacer una codificación dura separada para cada codificación de ancho variable.ĮDITAR: Esto ha sido algo probado, pero eso no quiere decir que todavía no tenga algunos errores sutiles. Cuando tenga codificación de tamaño variable (como UTF-8), tendrá que comprobar si está en medio de un personaje o no cuando obtiene datos. Leer archivos de texto al revés es realmente complicado a menos que esté utilizando una codificación de tamaño fijo (por ejemplo, ASCII).
