PageRenderTime 75ms CodeModel.GetById 40ms app.highlight 11ms RepoModel.GetById 19ms app.codeStats 1ms

/Lib/encodings/utf_7.py

http://unladen-swallow.googlecode.com/
Python | 38 lines | 38 code | 0 blank | 0 comment | 0 complexity | 59759c1acfce1edfa6338ae3106272e3 MD5 | raw file
 1""" Python 'utf-7' Codec
 2
 3Written by Brian Quinlan (brian@sweetapp.com).
 4"""
 5import codecs
 6
 7### Codec APIs
 8
 9encode = codecs.utf_7_encode
10
11def decode(input, errors='strict'):
12    return codecs.utf_7_decode(input, errors, True)
13
14class IncrementalEncoder(codecs.IncrementalEncoder):
15    def encode(self, input, final=False):
16        return codecs.utf_7_encode(input, self.errors)[0]
17
18class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
19    _buffer_decode = codecs.utf_7_decode
20
21class StreamWriter(codecs.StreamWriter):
22    encode = codecs.utf_7_encode
23
24class StreamReader(codecs.StreamReader):
25    decode = codecs.utf_7_decode
26
27### encodings module API
28
29def getregentry():
30    return codecs.CodecInfo(
31        name='utf-7',
32        encode=encode,
33        decode=decode,
34        incrementalencoder=IncrementalEncoder,
35        incrementaldecoder=IncrementalDecoder,
36        streamreader=StreamReader,
37        streamwriter=StreamWriter,
38    )