Decode a string encoded with RFC 2045 MIME header 'Q' encoding. This function does not parse a full MIME header value encoded with quoted-printable (like =?iso-8859-1?q?Hello_World?=) -- please use the high level email.header class for that functionality.
(s)
| 290 | |
| 291 | # Header decoding is done a bit differently |
| 292 | def header_decode(s): |
| 293 | """Decode a string encoded with RFC 2045 MIME header 'Q' encoding. |
| 294 | |
| 295 | This function does not parse a full MIME header value encoded with |
| 296 | quoted-printable (like =?iso-8859-1?q?Hello_World?=) -- please use |
| 297 | the high level email.header class for that functionality. |
| 298 | """ |
| 299 | s = s.replace('_', ' ') |
| 300 | return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s, flags=re.ASCII) |