2019-04-14 23:05:29 +03:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
pub fn encode_header(value: &str) -> String {
|
|
|
|
eprintln!("encoding \"{}\"", value);
|
2019-06-18 21:13:58 +03:00
|
|
|
let mut ret = String::with_capacity(value.len());
|
2019-04-14 23:05:29 +03:00
|
|
|
for word in value.split_whitespace() {
|
|
|
|
if word.is_ascii() {
|
|
|
|
ret.push_str(word);
|
|
|
|
} else {
|
|
|
|
ret.push_str(
|
2019-06-10 16:02:07 +03:00
|
|
|
format!("=?UTF-8?B?{}?=", BASE64_MIME.encode(word.trim().as_bytes())).trim(),
|
2019-04-14 23:05:29 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
ret.push(' ');
|
|
|
|
}
|
|
|
|
ret.pop();
|
|
|
|
ret
|
|
|
|
}
|