source: trunk/essentials/dev-lang/python/Lib/encodings/utf_7.py@ 3226

Last change on this file since 3226 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 1.1 KB
Line 
1""" Python 'utf-7' Codec
2
3Written by Brian Quinlan ([email protected]).
4"""
5import codecs
6
7### Codec APIs
8
9class Codec(codecs.Codec):
10
11 # Note: Binding these as C functions will result in the class not
12 # converting them to methods. This is intended.
13 encode = codecs.utf_7_encode
14 decode = codecs.utf_7_decode
15
16class IncrementalEncoder(codecs.IncrementalEncoder):
17 def encode(self, input, final=False):
18 return codecs.utf_7_encode(input, self.errors)[0]
19
20class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
21 def _buffer_decode(self, input, errors, final):
22 return codecs.utf_7_decode(input, self.errors)
23
24class StreamWriter(Codec,codecs.StreamWriter):
25 pass
26
27class StreamReader(Codec,codecs.StreamReader):
28 pass
29
30### encodings module API
31
32def getregentry():
33 return codecs.CodecInfo(
34 name='utf-7',
35 encode=Codec.encode,
36 decode=Codec.decode,
37 incrementalencoder=IncrementalEncoder,
38 incrementaldecoder=IncrementalDecoder,
39 streamreader=StreamReader,
40 streamwriter=StreamWriter,
41 )
Note: See TracBrowser for help on using the repository browser.