1 """ Generic Python Character Mapping Codec.
3 Use this codec directly rather than through the automatic
4 conversion mechanisms supplied by unicode() and .encode().
7 Written by Marc-Andre Lemburg (mal@lemburg.com).
9 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
17 class Codec(codecs
.Codec
):
19 # Note: Binding these as C functions will result in the class not
20 # converting them to methods. This is intended.
21 encode
= codecs
.charmap_encode
22 decode
= codecs
.charmap_decode
24 class StreamWriter(Codec
,codecs
.StreamWriter
):
26 def __init__(self
,stream
,errors
='strict',mapping
=None):
28 codecs
.StreamWriter
.__init
__(self
,stream
,errors
)
29 self
.mapping
= mapping
31 def encode(self
,input,errors
='strict'):
33 return Codec
.encode(input,errors
,self
.mapping
)
35 class StreamReader(Codec
,codecs
.StreamReader
):
37 def __init__(self
,stream
,errors
='strict',mapping
=None):
39 codecs
.StreamReader
.__init
__(self
,stream
,errors
)
40 self
.mapping
= mapping
42 def decode(self
,input,errors
='strict'):
44 return Codec
.decode(input,errors
,self
.mapping
)
46 ### encodings module API
50 return (Codec
.encode
,Codec
.decode
,StreamReader
,StreamWriter
)