1 | n/a | """ Python 'latin-1' Codec |
---|
2 | n/a | |
---|
3 | n/a | |
---|
4 | n/a | Written by Marc-Andre Lemburg (mal@lemburg.com). |
---|
5 | n/a | |
---|
6 | n/a | (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. |
---|
7 | n/a | |
---|
8 | n/a | """ |
---|
9 | n/a | import codecs |
---|
10 | n/a | |
---|
11 | n/a | ### Codec APIs |
---|
12 | n/a | |
---|
13 | n/a | class Codec(codecs.Codec): |
---|
14 | n/a | |
---|
15 | n/a | # Note: Binding these as C functions will result in the class not |
---|
16 | n/a | # converting them to methods. This is intended. |
---|
17 | n/a | encode = codecs.latin_1_encode |
---|
18 | n/a | decode = codecs.latin_1_decode |
---|
19 | n/a | |
---|
20 | n/a | class IncrementalEncoder(codecs.IncrementalEncoder): |
---|
21 | n/a | def encode(self, input, final=False): |
---|
22 | n/a | return codecs.latin_1_encode(input,self.errors)[0] |
---|
23 | n/a | |
---|
24 | n/a | class IncrementalDecoder(codecs.IncrementalDecoder): |
---|
25 | n/a | def decode(self, input, final=False): |
---|
26 | n/a | return codecs.latin_1_decode(input,self.errors)[0] |
---|
27 | n/a | |
---|
28 | n/a | class StreamWriter(Codec,codecs.StreamWriter): |
---|
29 | n/a | pass |
---|
30 | n/a | |
---|
31 | n/a | class StreamReader(Codec,codecs.StreamReader): |
---|
32 | n/a | pass |
---|
33 | n/a | |
---|
34 | n/a | class StreamConverter(StreamWriter,StreamReader): |
---|
35 | n/a | |
---|
36 | n/a | encode = codecs.latin_1_decode |
---|
37 | n/a | decode = codecs.latin_1_encode |
---|
38 | n/a | |
---|
39 | n/a | ### encodings module API |
---|
40 | n/a | |
---|
41 | n/a | def getregentry(): |
---|
42 | n/a | return codecs.CodecInfo( |
---|
43 | n/a | name='iso8859-1', |
---|
44 | n/a | encode=Codec.encode, |
---|
45 | n/a | decode=Codec.decode, |
---|
46 | n/a | incrementalencoder=IncrementalEncoder, |
---|
47 | n/a | incrementaldecoder=IncrementalDecoder, |
---|
48 | n/a | streamreader=StreamReader, |
---|
49 | n/a | streamwriter=StreamWriter, |
---|
50 | n/a | ) |
---|