utf_32_be.py 930 B

12345678910111213141516171819202122232425262728293031323334353637
  1. """
  2. Python 'utf-32-be' Codec
  3. """
  4. import codecs
  5. ### Codec APIs
  6. encode = codecs.utf_32_be_encode
  7. def decode(input, errors='strict'):
  8. return codecs.utf_32_be_decode(input, errors, True)
  9. class IncrementalEncoder(codecs.IncrementalEncoder):
  10. def encode(self, input, final=False):
  11. return codecs.utf_32_be_encode(input, self.errors)[0]
  12. class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
  13. _buffer_decode = codecs.utf_32_be_decode
  14. class StreamWriter(codecs.StreamWriter):
  15. encode = codecs.utf_32_be_encode
  16. class StreamReader(codecs.StreamReader):
  17. decode = codecs.utf_32_be_decode
  18. ### encodings module API
  19. def getregentry():
  20. return codecs.CodecInfo(
  21. name='utf-32-be',
  22. encode=encode,
  23. decode=decode,
  24. incrementalencoder=IncrementalEncoder,
  25. incrementaldecoder=IncrementalDecoder,
  26. streamreader=StreamReader,
  27. streamwriter=StreamWriter,
  28. )