Add character set properties to the global registry.
charset is the input character set, and must be the canonical name of a
character set.
Optional header_enc and body_enc is either Charset.QP for
quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for
the shortest of qp or base64 encoding, or None for no encoding. SHORTEST
is only valid for header_enc. It describes how message headers and
message bodies in the input charset are to be encoded. Default is no
encoding.
Optional output_charset is the character set that the output should be
in. Conversions will proceed from input charset, to Unicode, to the
output charset when the method Charset.convert() is called. The default
is to output in the same character set as the input.
Both input_charset and output_charset must have Unicode codec entries in
the module's charset-to-codec mapping; use add_codec(charset, codecname)
to add codecs the module does not know about. See the codecs module's
documentation for more information.

0010900110 def add_charset(charset, header_enc=None, body_enc=None, output_charset=None):
00111 """Add character set properties to the global registry.00112 00113 charset is the input character set, and must be the canonical name of a00114 character set.00115 00116 Optional header_enc and body_enc is either Charset.QP for00117 quoted-printable, Charset.BASE64 for base64 encoding, Charset.SHORTEST for00118 the shortest of qp or base64 encoding, or None for no encoding. SHORTEST00119 is only valid for header_enc. It describes how message headers and00120 message bodies in the input charset are to be encoded. Default is no00121 encoding.00122 00123 Optional output_charset is the character set that the output should be00124 in. Conversions will proceed from input charset, to Unicode, to the00125 output charset when the method Charset.convert() is called. The default00126 is to output in the same character set as the input.00127 00128 Both input_charset and output_charset must have Unicode codec entries in00129 the module's charset-to-codec mapping; use add_codec(charset, codecname)00130 to add codecs the module does not know about. See the codecs module's00131 documentation for more information.00132 """00133 if body_enc == SHORTEST:
00134 raise ValueError('SHORTEST not allowed for body_enc')
00135 CHARSETS[charset] = (header_enc, body_enc, output_charset)
00136

Add a codec that map characters in the given charset to/from Unicode.
charset is the canonical name of a character set. codecname is the name
of a Python codec, as appropriate for the second argument to the unicode()
built-in, or to the encode() method of a Unicode string.

0014600147 def add_codec(charset, codecname):
00148 """Add a codec that map characters in the given charset to/from Unicode.00149 00150 charset is the canonical name of a character set. codecname is the name00151 of a Python codec, as appropriate for the second argument to the unicode()00152 built-in, or to the encode() method of a Unicode string.00153 """00154 CODEC_MAP[charset] = codecname
00155
00156
00157
00158 # Convenience function for encoding strings, taking into account# that they might be unknown-8bit (ie: have surrogate-escaped bytes)