reference/filesystem/functions/fputcsv.xml
291d60430d25f2b508bebb5720b41cc68f9a6ec1
...
...
@@ -1,6 +1,6 @@
1
-
<?xml version="1.0" encoding="UTF-8"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fputcsv">
3
+
<refentry xml:id="function.fputcsv" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>fputcsv</refname>
6
6
<refpurpose>Format line as CSV and write to file pointer</refpurpose>
...
...
@@ -9,16 +9,18 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>int</type><methodname>fputcsv</methodname>
13
-
<methodparam><type>resource</type><parameter>handle</parameter></methodparam>
12
+
<type class="union"><type>int</type><type>false</type></type><methodname>fputcsv</methodname>
13
+
<methodparam><type>resource</type><parameter>stream</parameter></methodparam>
14
14
<methodparam><type>array</type><parameter>fields</parameter></methodparam>
15
-
<methodparam choice="opt"><type>string</type><parameter>delimiter</parameter><initializer>','</initializer></methodparam>
16
-
<methodparam choice="opt"><type>string</type><parameter>enclosure</parameter><initializer>'"'</initializer></methodparam>
15
+
<methodparam choice="opt"><type>string</type><parameter>separator</parameter><initializer>","</initializer></methodparam>
16
+
<methodparam choice="opt"><type>string</type><parameter>enclosure</parameter><initializer>"\""</initializer></methodparam>
17
+
<methodparam choice="opt"><type>string</type><parameter>escape</parameter><initializer>"\\"</initializer></methodparam>
18
+
<methodparam choice="opt"><type>string</type><parameter>eol</parameter><initializer>"\n"</initializer></methodparam>
17
19
</methodsynopsis>
18
20
<para>
19
21
<function>fputcsv</function> formats a line (passed as a
20
-
<parameter>fields</parameter> array) as CSV and write it (terminated by a
21
-
newline) to the specified file <parameter>handle</parameter>.
22
+
<parameter>fields</parameter> array) as CSV and writes it (terminated by a
23
+
newline) to the specified file <parameter>stream</parameter>.
22
24
</para>
23
25
</refsect1>
24
26

...
...
@@ -27,7 +29,7 @@
27
29
<para>
28
30
<variablelist>
29
31
<varlistentry>
30
-
<term><parameter>handle</parameter></term>
32
+
<term><parameter>stream</parameter></term>
31
33
<listitem>
32
34
&fs.validfp.all;
33
35
</listitem>
...
...
@@ -36,16 +38,16 @@
36
38
<term><parameter>fields</parameter></term>
37
39
<listitem>
38
40
<para>
39
-
An array of values.
41
+
An array of <type>string</type>s.
40
42
</para>
41
43
</listitem>
42
44
</varlistentry>
43
45
<varlistentry>
44
-
<term><parameter>delimiter</parameter></term>
46
+
<term><parameter>separator</parameter></term>
45
47
<listitem>
46
48
<para>
47
-
The optional <parameter>delimiter</parameter> parameter sets the field
48
-
delimiter (one character only).
49
+
The optional <parameter>separator</parameter> parameter sets the field
50
+
delimiter (one single-byte character only).
49
51
</para>
50
52
</listitem>
51
53
</varlistentry>
...
...
@@ -54,18 +56,75 @@
54
56
<listitem>
55
57
<para>
56
58
The optional <parameter>enclosure</parameter> parameter sets the field
57
-
enclosure (one character only).
59
+
enclosure (one single-byte character only).
60
+
</para>
61
+
</listitem>
62
+
</varlistentry>
63
+
<varlistentry>
64
+
<term><parameter>escape</parameter></term>
65
+
<listitem>
66
+
<para>
67
+
The optional <parameter>escape</parameter> parameter sets the
68
+
escape character (at most one single-byte character).
69
+
An empty string (<literal>""</literal>) disables the proprietary escape mechanism.
70
+
</para>
71
+
</listitem>
72
+
</varlistentry>
73
+
<varlistentry>
74
+
<term><parameter>eol</parameter></term>
75
+
<listitem>
76
+
<para>
77
+
The optional <parameter>eol</parameter> parameter sets
78
+
a custom End of Line sequence.
58
79
</para>
59
80
</listitem>
60
81
</varlistentry>
61
82
</variablelist>
62
83
</para>
84
+
<note>
85
+
<para>
86
+
If an <parameter>enclosure</parameter> character is contained in a field,
87
+
it will be escaped by doubling it, unless it is immediately preceded by an
88
+
<parameter>escape</parameter>.
89
+
</para>
90
+
</note>
63
91
</refsect1>
64
92

65
93
<refsect1 role="returnvalues">
66
94
&reftitle.returnvalues;
67
95
<para>
68
-
Returns the length of the written string&return.falseforfailure;.
96
+
Returns the length of the written string &return.falseforfailure;.
97
+
</para>
98
+
</refsect1>
99
+

100
+
<refsect1 role="changelog">
101
+
&reftitle.changelog;
102
+
<para>
103
+
<informaltable>
104
+
<tgroup cols="2">
105
+
<thead>
106
+
<row>
107
+
<entry>&Version;</entry>
108
+
<entry>&Description;</entry>
109
+
</row>
110
+
</thead>
111
+
<tbody>
112
+
<row>
113
+
<entry>8.1.0</entry>
114
+
<entry>
115
+
The optional <parameter>eol</parameter> parameter has been added.
116
+
</entry>
117
+
</row>
118
+
<row>
119
+
<entry>7.4.0</entry>
120
+
<entry>
121
+
The <parameter>escape</parameter> parameter now also accepts an empty
122
+
string to disable the proprietary escape mechanism.
123
+
</entry>
124
+
</row>
125
+
</tbody>
126
+
</tgroup>
127
+
</informaltable>
69
128
</para>
70
129
</refsect1>
71
130

...
...
@@ -122,7 +181,6 @@ aaa,bbb,ccc,dddd
122
181
</refsect1>
123
182

124
183
</refentry>
125
-

126
184
<!-- Keep this comment at the end of the file
127
185
Local variables:
128
186
mode: sgml
129
187