You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
476B

  1. use super::*;
  2. pub fn encode_header(value: &str) -> String {
  3. eprintln!("encoding \"{}\"", value);
  4. let mut ret = String::with_capacity(value.len());
  5. for word in value.split_whitespace() {
  6. if word.is_ascii() {
  7. ret.push_str(word);
  8. } else {
  9. ret.push_str(
  10. format!("=?UTF-8?B?{}?=", BASE64_MIME.encode(word.trim().as_bytes())).trim(),
  11. );
  12. }
  13. ret.push(' ');
  14. }
  15. ret.pop();
  16. ret
  17. }