A stream reader that automatically encodes the source byte stream into
unicode (like codecs.StreamReader
); but still supports the
seek()
and tell()
operations correctly. This
is in contrast to codecs.StreamReader
, which provide
*broken* seek()
and tell()
methods.
Note: this class requires stateless decoders. To my knowledge, this
shouldn't cause a problem with any of python's builtin unicode
encodings.
|
__init__(self,
stream,
encoding,
errors=' strict ' )
x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
source code
|
|
unicode
|
read(self,
size=None)
Read up to size bytes, decode them using this reader's
encoding, and return the resulting unicode string. |
source code
|
|
|
readline(self,
size=None)
Read a line of text, decode it using this reader's encoding, and
return the resulting unicode string. |
source code
|
|
list of unicode
|
readlines(self,
sizehint=None,
keepends=True)
Read this file's contents, decode them using this reader's encoding,
and return it as a list of unicode lines. |
source code
|
|
|
next(self)
Return the next decoded line from the underlying stream. |
source code
|
|
|
|
|
|
|
|
|
seek(self,
offset,
whence=0)
Move the stream to a new file position. |
source code
|
|
|
char_seek_forward(self,
offset)
Move the read pointer forward by offset characters. |
source code
|
|
|
|
|
tell(self)
Return the current file position on the underlying byte stream. |
source code
|
|
|
_read(self,
size=None)
Read up to size bytes from the underlying stream, decode
them using this reader's encoding, and return the resulting unicode
string. |
source code
|
|
|
_incr_decode(self,
bytes)
Decode the given byte string into a unicode string, using this
reader's encoding. |
source code
|
|
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
|
stream
The underlying stream.
|
|
encoding
The name of the encoding that should be used to encode the underlying
stream.
|
|
errors
The error mode that should be used when decoding data from the
underlying stream.
|
|
decode
The function that is used to decode byte strings into unicode
strings.
|
|
bytebuffer
A buffer to use bytes that have been read but have not yet been
decoded.
|
|
linebuffer
A buffer used by readline() to hold characters that have been read,
but have not yet been returned by read() or readline().
|
|
_rewind_checkpoint
The file position at which the most recent read on the underlying
stream began.
|
|
_rewind_numchars
The number of characters that have been returned since the read that
started at _rewind_checkpoint.
|
|
_bom
The length of the byte order marker at the beginning of the stream
(or None for no byte order marker).
|