@@ -31,7 +31,8 @@ class Csv extends AbstractAdapter implements ArrayAccess
31
31
* @param array $options = [
32
32
* 'content' => '',
33
33
* 'delimiter' => ';',
34
- * 'enclosure' => '"'
34
+ * 'enclosure' => '"',
35
+ * 'escape' => '\\'
35
36
* ]
36
37
*
37
38
* @throws Exception
@@ -40,7 +41,7 @@ class Csv extends AbstractAdapter implements ArrayAccess
40
41
<InterpolatorFactory> interpolator,
41
42
array options
42
43
) {
43
- var delimiter, enclosure;
44
+ var delimiter, enclosure, escape ;
44
45
45
46
parent :: __construct(interpolator, options);
46
47
@@ -60,7 +61,13 @@ class Csv extends AbstractAdapter implements ArrayAccess
60
61
let enclosure = " \" " ;
61
62
}
62
63
63
- this -> load(options[" content" ], 0 , delimiter, enclosure);
64
+ if isset options[" escape" ] {
65
+ let escape = options[" escape" ];
66
+ } else {
67
+ let escape = " \\ " ;
68
+ }
69
+
70
+ this -> load(options[" content" ], 0 , delimiter, enclosure, escape);
64
71
}
65
72
66
73
/**
@@ -114,10 +121,11 @@ class Csv extends AbstractAdapter implements ArrayAccess
114
121
* @param int $length
115
122
* @param string $separator
116
123
* @param string $enclosure
124
+ * @param string $escape
117
125
*
118
126
* @throws Exception
119
127
*/
120
- private function load (string file, int length, string delimiter, string enclosure ) -> void
128
+ private function load (string file, int length, string delimiter, string enclosure, string escape ) -> void
121
129
{
122
130
var data, fileHandler;
123
131
@@ -130,7 +138,7 @@ class Csv extends AbstractAdapter implements ArrayAccess
130
138
}
131
139
132
140
loop {
133
- let data = fgetcsv(fileHandler, length, delimiter, enclosure);
141
+ let data = fgetcsv(fileHandler, length, delimiter, enclosure, escape );
134
142
135
143
if data === false {
136
144
break ;
0 commit comments