Skip to main content

encode_words

Function encode_words 

Source
pub fn encode_words(
    text: &str,
    room_first_line: usize,
    out: &mut impl Sink,
) -> Result<(), WriteError>
Expand description

Writes text for an unstructured header field: as it is when it is printable ASCII without =?, otherwise as RFC 2047 =?UTF-8?Q?...?= words of at most 75 bytes, split only between characters, separated by CRLF SP. The first word fits in room_first_line (the columns left after Name: ); when not even one character fits there, the words start on a new line.

§Errors

WriteError::Forbidden for a control character (C0, DEL, or C1); WriteError::Full (nothing written when the sink reports its room).

§Examples

use parse_net::{mail, SliceSink};

let mut buf = [0u8; 256];
let mut out = SliceSink::new(&mut buf);
mail::encode_words("Caf\u{e9} au lait", 64, &mut out).expect("room");
assert_eq!(out.written(), b"=?UTF-8?Q?Caf=C3=A9_au_lait?=");