Lines Matching refs:charset
16 import email.charset
43 three tuple (charset, language, value), it will be encoded according
48 # are (charset, language, value). charset is a string, not a Charset
220 def set_payload(self, payload, charset=None):
223 Optional charset sets the message's default character set. See
227 if charset is not None:
228 self.set_charset(charset)
230 def set_charset(self, charset):
231 """Set the charset of the payload to a given character set.
233 charset can be a Charset instance, a string naming a character set, or
234 None. If it is a string it will be converted to a Charset instance.
235 If charset is None, the charset parameter will be removed from the
239 charset.input_charset. It will be converted to charset.output_charset
245 if charset is None:
246 self.del_param('charset')
249 if isinstance(charset, basestring):
250 charset = email.charset.Charset(charset)
251 if not isinstance(charset, email.charset.Charset):
252 raise TypeError(charset)
254 # Charset constructor?
255 self._charset = charset
260 charset=charset.get_output_charset())
262 self.set_param('charset', charset.get_output_charset())
264 self._payload = self._payload.encode(charset.output_charset)
265 if str(charset) != charset.get_output_charset():
266 self._payload = charset.body_encode(self._payload)
268 cte = charset.get_body_encoding()
272 self._payload = charset.body_encode(self._payload)
276 """Return the Charset instance associated with the message's payload.
398 three-tuple of (charset, language, value), in which case it will be
548 the form (CHARSET, LANGUAGE, VALUE). Note that both CHARSET and
550 encoded in the us-ascii charset. You can usually ignore LANGUAGE.
574 charset=None, language=''):
587 If charset is specified, the parameter will be encoded according to RFC
589 to the empty string. Both charset and language should be strings.
591 if not isinstance(value, tuple) and charset:
592 value = (charset, language, value)
750 """Return the charset parameter of the Content-Type header.
753 Content-Type header, or if that header has no charset parameter,
757 charset = self.get_param('charset', missing)
758 if charset is missing:
760 if isinstance(charset, tuple):
762 pcharset = charset[0] or 'us-ascii'
764 # LookupError will be raised if the charset isn't known to
766 # contains a character not in the charset.
767 charset = unicode(charset[2], pcharset).encode('us-ascii')
769 charset = charset[2]
770 # charset character must be in us-ascii range
772 if isinstance(charset, str):
773 charset = unicode(charset, 'us-ascii')
774 charset = charset.encode('us-ascii')
778 return charset.lower()
781 """Return a list containing the charset(s) used in this message.
784 charset parameter for this message and all the subparts in its
787 Each item will either be a string (the value of the charset parameter
790 main MIME type of "text", or the charset is not defined.