Skip to main content

csv_escape

Function csv_escape 

Source
pub fn csv_escape(s: &str) -> String
Expand description

Escape a string for CSV per RFC 4180. If the string contains comma, double quote, or newline, wrap in quotes and escape quotes.

ยงExamples

use perfgate_export::csv_escape;

assert_eq!(csv_escape("hello"), "hello");
assert_eq!(csv_escape("has,comma"), "\"has,comma\"");
assert_eq!(csv_escape("has\"quote"), "\"has\"\"quote\"");