Function csv_core::quote
[−]
[src]
pub fn quote(
input: &[u8],
output: &mut [u8],
quote: u8,
escape: u8,
double_quote: bool
) -> (WriteResult, usize, usize)
Escape quotes input and writes the result to output.
If input does not have a quote, then the contents of input are
copied verbatim to output.
If output is not big enough to store the fully quoted contents of
input, then WriteResult::OutputFull is returned. The output buffer
will require a maximum of storage of 2 * input.len() in the worst case
(where every byte is a quote).
In streaming contexts, quote should be called in a loop until
WriteResult::InputEmpty is returned. It is possible to write an infinite
loop if your output buffer is less than 2 bytes in length (the minimum
storage space required to store an escaped quote).
In addition to the WriteResult, the number of consumed bytes from input
and the number of bytes written to output are also returned.
quote is the quote byte and escape is the escape byte. If
double_quote is true, then quotes are escaped by doubling them,
otherwise, quotes are escaped with the escape byte.
N.B. This function is provided for low level usage. It is called
automatically if you're using a Writer.