pub fn decode<T: AsRef<str>>(ew: T) -> Result<DecodingResult, DecodingError>
Expand description

Decode encoded word and return (string, charset, lang, defects) tuple.

An RFC 2047/2243 encoded word has the form: =?charset*lang?cte?encoded_string?=

where ‘*lang’ may be omitted but the other parts may not be.

This function expects exactly such a string (that is, it does not check the syntax and may raise errors if the string is not well formed), and returns the encoded_string decoded first from its Content Transfer Encoding and then from the resulting bytes into unicode using the specified charset. If the cte-decoded string does not successfully decode using the specified character set, a defect is added to the defects list and the unknown octets are replaced by the unicode ‘unknown’ character \uFDFF.

The specified charset and language are returned. The default for language, which is rarely if ever encountered, is the empty string.