1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use super::rfc3501::is_quoted_specials;

pub fn quote_string(input: impl AsRef<[u8]>) -> Vec<u8> {
    let input = input.as_ref();
    let mut ret = Vec::with_capacity(input.len() + 2);

    ret.push(b'\x22');
    for c in input {
        if is_quoted_specials(*c) {
            ret.push(b'\\');
        }
        ret.push(*c);
    }
    ret.push(b'\x22');

    ret
}