@@ -3,6 +3,8 @@ extension CSVWriter {
33 public struct Configuration {
44 /// The field and row delimiters.
55 public var delimiters : Delimiter . Pair
6+ /// The strategy for escaping quoted fields.
7+ public var escapingStrategy : Strategy . Escaping
68 /// The row of headers to write at the beginning of the CSV data.
79 ///
810 /// If empty, no row will be written.
@@ -19,6 +21,7 @@ extension CSVWriter {
1921 /// Designated initlaizer setting the default values.
2022 public init ( ) {
2123 self . delimiters = ( field: " , " , row: " \n " )
24+ self . escapingStrategy = . doubleQuote
2225 self . headers = . init( )
2326 self . encoding = nil
2427 self . bomStrategy = . convention
@@ -53,7 +56,7 @@ extension CSVWriter {
5356 /// Boolean indicating whether the received CSV contains a header row or not.
5457 let headers : [ String ]
5558 /// The unicode scalar used as encapsulator and escaping character (when printed two times).
56- let escapingScalar : Unicode . Scalar ? = " \" "
59+ let escapingScalar : Unicode . Scalar ?
5760 /// The encoding used to identify the underlying data.
5861 let encoding : String . Encoding
5962
@@ -71,6 +74,7 @@ extension CSVWriter {
7174 self . delimiters = ( . init( field) , . init( row) )
7275 }
7376 // 2. Copy all other values.
77+ self . escapingScalar = configuration. escapingStrategy. scalar
7478 self . headers = configuration. headers
7579 self . encoding = encoding
7680 }
0 commit comments