utf_16_le.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """ Python 'utf-16-le' Codec
  2. Written by Marc-Andre Lemburg (mal@lemburg.com).
  3. (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
  4. """
  5. import codecs
  6. ### Codec APIs
  7. encode = codecs.utf_16_le_encode
  8. def decode(input, errors='strict'):
  9. return codecs.utf_16_le_decode(input, errors, True)
  10. class IncrementalEncoder(codecs.IncrementalEncoder):
  11. def encode(self, input, final=False):
  12. return codecs.utf_16_le_encode(input, self.errors)[0]
  13. class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
  14. _buffer_decode = codecs.utf_16_le_decode
  15. class StreamWriter(codecs.StreamWriter):
  16. encode = codecs.utf_16_le_encode
  17. class StreamReader(codecs.StreamReader):
  18. decode = codecs.utf_16_le_decode
  19. ### encodings module API
  20. def getregentry():
  21. return codecs.CodecInfo(
  22. name='utf-16-le',
  23. encode=encode,
  24. decode=decode,
  25. incrementalencoder=IncrementalEncoder,
  26. incrementaldecoder=IncrementalDecoder,
  27. streamreader=StreamReader,
  28. streamwriter=StreamWriter,
  29. )