You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/9.0/connections/bom.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,10 @@ title: BOM sequence detection and addition
5
5
6
6
# BOM sequences
7
7
8
-
## Detecting the BOM sequence
8
+
## Definition
9
9
10
10
To improve interoperability with programs interacting with CSV, the package now provides an enum `Bom` to help you detect the appropriate <abbrtitle="Byte Order Mark">BOM</abbr> sequence.
11
11
12
-
### BOM definition
13
-
14
12
The `Bom` enum provides the following value :
15
13
16
14
-`Bom::Utf8` : which handles the `UTF-8``BOM` sequence;
@@ -19,7 +17,9 @@ The `Bom` enum provides the following value :
19
17
-`Bom::utf32Be` : which handles the `UTF-32``BOM` with Big-Endian sequence;
20
18
-`Bom::utf32Le` : which handles the `UTF-32``BOM` with Little-Endian sequence;
21
19
22
-
### Detecting the BOM from a sequence of characters
The resulting data is converted from `iso-8859-15` to the default `UTF-8` since no output encoding charset was set using the `CharsertConverter::outputEncoding` method.
42
42
43
-
## CharsetConverter as a Writer formatter
43
+
## As a Writer formatter
44
44
45
45
```php
46
46
public CharsetConverter::__invoke(array $record): array
//all 'utf-8' characters are now automatically encoded into 'iso-8859-15' charset
65
65
```
66
66
67
-
## CharsetConverter as a PHP stream filter
67
+
## As a PHP stream filter
68
68
69
69
```php
70
70
public static CharsetConverter::addTo(AbstractCsv $csv, string $input_encoding, string $output_encoding): AbstractCsv
71
71
public static CharsetConverter::register(): void
72
72
public static CharsetConverter::getFiltername(string $input_encoding, string $output_encoding): string
73
73
```
74
74
75
-
### Usage with CSV objects
75
+
### With CSV object
76
76
77
-
If your CSV object supports PHP stream filters then you can use the `CharsetConverter` class as a PHP stream filter using the library [stream filtering mechanism](/9.0/connections/filters/) instead.
77
+
If your CSV object supports PHP stream filters; then you can use the `CharsetConverter` class as a PHP stream filter using the library [stream filtering mechanism](/9.0/connections/filters/) instead.
78
78
79
79
The `CharsetConverter::addTo` static method:
80
80
81
81
- registers the `CharsetConverter` class under the generic filtername `convert.league.csv.*` if it is not registered yet;
82
-
-configures the stream filter using the supplied parameters;
82
+
-configure the stream filter using the supplied parameters;
83
83
- adds the configured stream filter to the submitted CSV object;
Copy file name to clipboardExpand all lines: docs/9.0/index.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,7 @@ layout: default
13
13
14
14
**League\Csv** is a simple library to ease CSV document [loading](/9.0/connections/) as well as [writing](/9.0/writer/), [selecting](/9.0/reader/) and [converting](/9.0/converter/) CSV records.
15
15
16
-
## Usage
17
-
18
-
### Parsing a CSV document
16
+
## Parsing a CSV document
19
17
20
18
Access and filter records from a CSV document saved on the local filesystem.
21
19
@@ -39,7 +37,7 @@ foreach ($records as $record) {
39
37
}
40
38
```
41
39
42
-
###Exporting a database table as a CSV document
40
+
## Exporting a database table as a CSV document
43
41
44
42
Fetch data using a `PDOStatement` object, then create a CSV document which is output to the browser.
45
43
@@ -76,7 +74,7 @@ $csv->output('users.csv');
76
74
die;
77
75
```
78
76
79
-
###Importing CSV records into a database table
77
+
## Importing CSV records into a database table
80
78
81
79
Import records from a CSV document into a database using a `PDOStatement` object
82
80
@@ -104,7 +102,7 @@ foreach ($csv as $record) {
104
102
}
105
103
```
106
104
107
-
###Encoding a CSV document into a given charset
105
+
## Encoding a CSV document into a given charset
108
106
109
107
It is not possible to detect the character encoding a CSV document (e.g. `UTF-8`, `UTF-16`, etc). However, it *is* possible to detect the input BOM and convert to UTF-8 where necessary.
110
108
@@ -127,7 +125,7 @@ foreach ($csv as $record) {
127
125
}
128
126
```
129
127
130
-
###Converting a CSV document into a XML document
128
+
## Converting a CSV document into a XML document
131
129
132
130
The `XMLConverter` object provided by this package can easily convert a CSV document into a `DOMDocument` object.
Copy file name to clipboardExpand all lines: docs/9.0/interoperability/enclose-field.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The `EncloseField` is a PHP stream filter which forces the `Writer` class to enc
16
16
<code>Writer::forceEnclosure</code> method for better results and improved DX. Please refer to
17
17
<ahref="/9.0/writer/#force-enclosure">its documentation</a> for more informations.</p>
18
18
19
-
## Usage with Writer objects
19
+
## With Writer objects
20
20
21
21
```php
22
22
public static EncloseField::addTo(Writer $csv, string $sequence): Writer
@@ -40,7 +40,7 @@ $writer->output('mycsvfile.csv'); //outputting a CSV Document with all its field
40
40
41
41
<pclass="message-warning">The <code>$sequence</code> argument should be a sequence containing at least one character that forces <code>fputcsv</code> to enclose the field value. If not, an <code>InvalidArgumentException</code> exception will be thrown.</p>
Copy file name to clipboardExpand all lines: docs/9.0/interoperability/rfc4180-field.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ When using this stream filter you can easily create or read a [RFC4180 compliant
18
18
19
19
<pclass="message-warning">Changing the CSV objects control characters <strong>after registering the stream filter</strong> may result in unexpected returned records.</p>
20
20
21
-
## Usage with League\CSV objects
21
+
## With CSV objects
22
22
23
23
```php
24
24
public static RFC4180Field::addTo(AbstractCsv $csv, string $whitespace_replace = ''): AbstractCsv
echo $writer->getContent(); //display ' o bar,baz' instead of 'foo bar,baz'
75
75
```
76
76
77
-
### On records insertion
77
+
### On Records Insertion
78
78
79
79
<pclass="message-info">To fully comply with <code>RFC4180</code> you will also need to use <code>League\Csv\Writer::setNewline</code>.</p>
80
80
81
-
### On records extraction
81
+
### On Records Extraction
82
82
83
83
Conversely, to read a RFC4180 compliant CSV document, when using the `League\Csv\Reader` object, you just need to add the `League\Csv\RFC4180Field` stream filter as shown below:
0 commit comments