You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cp1252.py 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. """ Python Character Mapping Codec generated from 'CP1252.TXT' with gencodec.py.
  2. Written by Marc-Andre Lemburg (mal@lemburg.com).
  3. (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
  4. (c) Copyright 2000 Guido van Rossum.
  5. """#"
  6. import codecs
  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 = codecs.make_identity_dict(range(256))
  22. decoding_map.update({
  23. 0x0080: 0x20ac, # EURO SIGN
  24. 0x0081: None, # UNDEFINED
  25. 0x0082: 0x201a, # SINGLE LOW-9 QUOTATION MARK
  26. 0x0083: 0x0192, # LATIN SMALL LETTER F WITH HOOK
  27. 0x0084: 0x201e, # DOUBLE LOW-9 QUOTATION MARK
  28. 0x0085: 0x2026, # HORIZONTAL ELLIPSIS
  29. 0x0086: 0x2020, # DAGGER
  30. 0x0087: 0x2021, # DOUBLE DAGGER
  31. 0x0088: 0x02c6, # MODIFIER LETTER CIRCUMFLEX ACCENT
  32. 0x0089: 0x2030, # PER MILLE SIGN
  33. 0x008a: 0x0160, # LATIN CAPITAL LETTER S WITH CARON
  34. 0x008b: 0x2039, # SINGLE LEFT-POINTING ANGLE QUOTATION MARK
  35. 0x008c: 0x0152, # LATIN CAPITAL LIGATURE OE
  36. 0x008d: None, # UNDEFINED
  37. 0x008e: 0x017d, # LATIN CAPITAL LETTER Z WITH CARON
  38. 0x008f: None, # UNDEFINED
  39. 0x0090: None, # UNDEFINED
  40. 0x0091: 0x2018, # LEFT SINGLE QUOTATION MARK
  41. 0x0092: 0x2019, # RIGHT SINGLE QUOTATION MARK
  42. 0x0093: 0x201c, # LEFT DOUBLE QUOTATION MARK
  43. 0x0094: 0x201d, # RIGHT DOUBLE QUOTATION MARK
  44. 0x0095: 0x2022, # BULLET
  45. 0x0096: 0x2013, # EN DASH
  46. 0x0097: 0x2014, # EM DASH
  47. 0x0098: 0x02dc, # SMALL TILDE
  48. 0x0099: 0x2122, # TRADE MARK SIGN
  49. 0x009a: 0x0161, # LATIN SMALL LETTER S WITH CARON
  50. 0x009b: 0x203a, # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
  51. 0x009c: 0x0153, # LATIN SMALL LIGATURE OE
  52. 0x009d: None, # UNDEFINED
  53. 0x009e: 0x017e, # LATIN SMALL LETTER Z WITH CARON
  54. 0x009f: 0x0178, # LATIN CAPITAL LETTER Y WITH DIAERESIS
  55. })
  56. ### Encoding Map
  57. encoding_map = {}
  58. for k,v in decoding_map.items():
  59. encoding_map[v] = k