2001-09-20 09:56:14 -03:00
|
|
|
""" Python 'utf-7' Codec
|
|
|
|
|
|
|
|
Written by Brian Quinlan (brian@sweetapp.com).
|
|
|
|
"""
|
|
|
|
import codecs
|
|
|
|
|
|
|
|
### Codec APIs
|
|
|
|
|
2007-11-20 19:38:09 -04:00
|
|
|
encode = codecs.utf_7_encode
|
2001-09-20 09:56:14 -03:00
|
|
|
|
2007-11-20 19:38:09 -04:00
|
|
|
def decode(input, errors='strict'):
|
|
|
|
return codecs.utf_7_decode(input, errors, True)
|
2001-09-20 09:56:14 -03:00
|
|
|
|
2006-04-21 06:43:23 -03:00
|
|
|
class IncrementalEncoder(codecs.IncrementalEncoder):
|
|
|
|
def encode(self, input, final=False):
|
|
|
|
return codecs.utf_7_encode(input, self.errors)[0]
|
|
|
|
|
|
|
|
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
2007-11-20 19:38:09 -04:00
|
|
|
_buffer_decode = codecs.utf_7_decode
|
2006-04-21 06:43:23 -03:00
|
|
|
|
2007-11-20 19:38:09 -04:00
|
|
|
class StreamWriter(codecs.StreamWriter):
|
|
|
|
encode = codecs.utf_7_encode
|
2002-08-08 17:19:19 -03:00
|
|
|
|
2007-11-20 19:38:09 -04:00
|
|
|
class StreamReader(codecs.StreamReader):
|
|
|
|
decode = codecs.utf_7_decode
|
2001-09-20 09:56:14 -03:00
|
|
|
|
|
|
|
### encodings module API
|
|
|
|
|
|
|
|
def getregentry():
|
2006-04-21 06:43:23 -03:00
|
|
|
return codecs.CodecInfo(
|
|
|
|
name='utf-7',
|
2007-11-20 19:38:09 -04:00
|
|
|
encode=encode,
|
|
|
|
decode=decode,
|
2006-04-21 06:43:23 -03:00
|
|
|
incrementalencoder=IncrementalEncoder,
|
|
|
|
incrementaldecoder=IncrementalDecoder,
|
|
|
|
streamreader=StreamReader,
|
|
|
|
streamwriter=StreamWriter,
|
|
|
|
)
|