rust-email
rust-email copied to clipboard
Support RFC2047 encoding on Header's to_string
Headers should (as required) use RFC2047 encoding when being coerced into a string for inclusion in a MimeMessage.
It should:
- [ ] Support determination of charset encoding as determined by the user, but default to UTF-8
- [ ] Decide automagically if it should use Q encoding or BASE64, based on whichever is shorter
- [ ] Play nicely with header folding (Perhaps ToFoldedHeader should have a requirement to have handled encoding yourself)
- [ ] Not need to do any special manipulation to strings that are already 7-bit ASCII.
I'm two layers downstream and needed this, so I implemented an RFC 2047 encoder. It doesn't tick all of the boxes from above yet, but I believe it does q-encoding correctly, which should cover the hardest part: https://crates.io/crates/rfc2047