Function mung::decode_rfc2047 [] [src]

pub fn decode_rfc2047<'a>(s: &'a str) -> Cow<'a, str>

Decodes RFC 2047 encoded words into their UTF-8 form

See: Message Header Extensions for Non-ASCII Text https://tools.ietf.org/html/rfc2047 See also: base64 specification https://tools.ietf.org/html/rfc2045#page-24

For those unfamiliar, a base64 encoded Latin alphabet no. 1 string:

=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IHVuZGVyc3RhbmQgdGhlIGV4YW1wbGUu?=

decodes to If you can read this you understand the example.

Known caveat of this function is that it returns as UTF-8; if you are decoding into another character set, be aware you will need a further conversion.

Examples

Can be called with &' str

use mung::decode_rfc2047;
let subject = decode_rfc2047( "Subject: =?GB2312?B?s8m5prXEsvrGt76twO0=?=" );