cp1140.py 886 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """ Python Character Mapping Codec for cp1140
  2. Written by Brian Quinlan([email protected]). NO WARRANTY.
  3. """
  4. import codecs
  5. import copy
  6. import cp037
  7. ### Codec APIs
  8. class Codec(codecs.Codec):
  9. def encode(self,input,errors='strict'):
  10. return codecs.charmap_encode(input,errors,encoding_map)
  11. def decode(self,input,errors='strict'):
  12. return codecs.charmap_decode(input,errors,decoding_map)
  13. class StreamWriter(Codec,codecs.StreamWriter):
  14. pass
  15. class StreamReader(Codec,codecs.StreamReader):
  16. pass
  17. ### encodings module API
  18. def getregentry():
  19. return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
  20. ### Decoding Map
  21. decoding_map = copy.copy(cp037.decoding_map)
  22. decoding_map.update({
  23. 0x009f: 0x20ac # EURO SIGN
  24. })
  25. ### Encoding Map
  26. encoding_map = codecs.make_encoding_map(decoding_map)