iso2022_jp_ext.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #
  2. # iso2022_jp_ext.py: Python Unicode Codec for ISO2022_JP_EXT
  3. #
  4. # Written by Hye-Shik Chang <perky@FreeBSD.org>
  5. #
  6. import _codecs_iso2022, codecs
  7. import _multibytecodec as mbc
  8. codec = _codecs_iso2022.getcodec('iso2022_jp_ext')
  9. class Codec(codecs.Codec):
  10. encode = codec.encode
  11. decode = codec.decode
  12. class IncrementalEncoder(mbc.MultibyteIncrementalEncoder,
  13. codecs.IncrementalEncoder):
  14. codec = codec
  15. class IncrementalDecoder(mbc.MultibyteIncrementalDecoder,
  16. codecs.IncrementalDecoder):
  17. codec = codec
  18. class StreamReader(Codec, mbc.MultibyteStreamReader, codecs.StreamReader):
  19. codec = codec
  20. class StreamWriter(Codec, mbc.MultibyteStreamWriter, codecs.StreamWriter):
  21. codec = codec
  22. def getregentry():
  23. return codecs.CodecInfo(
  24. name='iso2022_jp_ext',
  25. encode=Codec().encode,
  26. decode=Codec().decode,
  27. incrementalencoder=IncrementalEncoder,
  28. incrementaldecoder=IncrementalDecoder,
  29. streamreader=StreamReader,
  30. streamwriter=StreamWriter,
  31. )