[][src]Function encoded_words::encode

pub fn encode<T: AsRef<str>>(
    ew: T,
    charset: Option<Charset>,
    encoding_flag: EncodingFlag,
    lang: Option<&str>
) -> String

Encode string using the CTE encoding that produces the shorter result.

Produces an RFC 2047/2243 encoded word of the form: =?charset*lang?cte?encoded_string?=

where '*lang' is omitted unless the 'lang' parameter is given a value. Optional argument charset (defaults to utf-8) specifies the charset to use to encode the string to binary before CTE encoding it. Optional argument 'encoding' is the cte specifier for the encoding that should be used ('q' or 'b'); if it is None (the default) the encoding which produces the shortest encoded sequence is used, except that 'q' is preferred if it is up to five characters longer. Optional argument 'lang' (default '') gives the RFC 2243 language string to specify in the encoded word.