BOM_BE = BOM32_BE = '\376\377'
# corresponds to Unicode U+FEFF in UTF-16 on big endian
# platforms == ZERO WIDTH NO-BREAK SPACE
-BOM_LE = BOM32_LE = '\377\376'
+BOM_LE = BOM32_LE = '\377\376'
# corresponds to Unicode U+FFFE in UTF-16 on little endian
# platforms == defined as being an illegal Unicode character
""" Encodes the object input and returns a tuple (output
object, length consumed).
input must be an object which provides the bf_getreadbuf
buffer slot. Python strings, buffer objects and memory
mapped files are examples of objects providing this slot.
errors defines the error handling to apply. It defaults to
return an empty object of the output object type in this
# interfaces which can be used to implement new encodings submodules
# very easily. See encodings/utf_8.py for an example on how this is
""" Flushes and resets the codec buffers used for keeping state.
size, if given, is passed as size argument to the stream's
line = self.stream.readline()
line = self.stream.readline(size)
def readlines(self, sizehint=0):
Line breaks are implemented using the codec's decoder
method and are included in the list entries.
sizehint, if given, is passed as size argument to the
""" Creates a StreamRecoder instance which implements a two-way
conversion: encode and decode work on the frontend (the
- input to .read() and output of .write()) while
+ input to .read() and output of .write()) while
Reader and Writer work on the backend (reading and
if __name__ == '__main__':
# Make stdout translate Latin-1 output into UTF-8 output
sys.stdout = EncodedFile(sys.stdout, 'latin-1', 'utf-8')
# Have stdin translate Latin-1 input into UTF-8 input
sys.stdin = EncodedFile(sys.stdin, 'utf-8', 'latin-1')