1 """Codec for quoted-printable encoding.
3 Like base64 and rot13, this returns Python strings, not Unicode.
8 from cStringIO
import StringIO
10 from StringIO
import StringIO
12 def quopri_encode(input, errors
='strict'):
13 """Encode the input, returning a tuple (output object, length consumed).
15 errors defines the error handling to apply. It defaults to
16 'strict' handling which is the only currently supported
17 error handling for this codec.
20 assert errors
== 'strict'
23 quopri
.encode(f
, g
, 1)
25 return (output
, len(input))
27 def quopri_decode(input, errors
='strict'):
28 """Decode the input, returning a tuple (output object, length consumed).
30 errors defines the error handling to apply. It defaults to
31 'strict' handling which is the only currently supported
32 error handling for this codec.
35 assert errors
== 'strict'
40 return (output
, len(input))
42 class Codec(codecs
.Codec
):
44 def encode(self
, input,errors
='strict'):
45 return quopri_encode(input,errors
)
46 def decode(self
, input,errors
='strict'):
47 return quopri_decode(input,errors
)
49 class StreamWriter(Codec
, codecs
.StreamWriter
):
52 class StreamReader(Codec
,codecs
.StreamReader
):
55 # encodings module API
58 return (quopri_encode
, quopri_decode
, StreamReader
, StreamWriter
)