1 """ Test Codecs (used by test_charmapcodec)
3 Written by Marc-Andre Lemburg (mal@lemburg.com).
5 (c) Copyright 2000 Guido van Rossum.
12 class Codec(codecs
.Codec
):
14 def encode(self
,input,errors
='strict'):
16 return codecs
.charmap_encode(input,errors
,encoding_map
)
18 def decode(self
,input,errors
='strict'):
20 return codecs
.charmap_decode(input,errors
,decoding_map
)
22 class StreamWriter(Codec
,codecs
.StreamWriter
):
25 class StreamReader(Codec
,codecs
.StreamReader
):
28 ### encodings module API
32 return (Codec().encode
,Codec().decode
,StreamReader
,StreamWriter
)
36 decoding_map
= codecs
.make_identity_dict(range(256))
38 0x78: u
"abc", # 1-n decoding mapping
39 "abc": 0x0078,# 1-n encoding mapping
40 0x01: None, # decoding mapping to <undefined>
41 0x79: u
"", # decoding mapping to <remove character>
47 for k
,v
in decoding_map
.items():