1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-24 15:52:15 +01:00

Clarify behaviour of escape parameter and how it handles enclosure bytes (#5006)

This commit is contained in:
Narkunan
2026-01-09 18:24:39 +05:30
committed by GitHub
parent c142be8117
commit e1fd0bef1d
2 changed files with 18 additions and 20 deletions

View File

@@ -88,18 +88,17 @@
It must be a single byte character or the empty string.
The empty string (<literal>""</literal>) disables the proprietary escape mechanism.
</para>
<note>
<warning>
<simpara>
Usually an <parameter>enclosure</parameter> character is escaped inside
a field by doubling it; however, the <parameter>escape</parameter>
character can be used as an alternative. So for the default parameter
values <literal>""</literal> and <literal>\"</literal> have the same
meaning. Other than allowing to escape the
<parameter>enclosure</parameter> character the
<parameter>escape</parameter> character has no special meaning; it isn't
even meant to escape itself.
Inside an <parameter>enclosure</parameter>, the <parameter>enclosure</parameter> character can always be <parameter>escaped</parameter> by doubling it,
resulting in a single <parameter>enclosure</parameter> character in the parsed result.
The <parameter>escaped</parameter> character works differently:
If it is followed by an <parameter>enclosure</parameter> character then that <parameter>enclosure</parameter> character will not be treated as one,
however the <parameter>escaped</parameter> character itself remains. So for the default parameters, <literal>""</literal>
inside an <parameter>enclosure</parameter> will be parsed into <literal>",</literal> while <literal>\"</literal> inside an
<parameter>enclosure</parameter> will be parsed into <literal>\"</literal>.
</simpara>
</note>
</warning>
<warning>
<simpara>
As of PHP 8.4.0, depending on the default value of

View File

@@ -55,18 +55,17 @@
<methodname>SplFileObject::setCsvControl</methodname>.
An empty string (<literal>""</literal>) disables the proprietary escape mechanism.
</para>
<note>
<warning>
<simpara>
Usually an <parameter>enclosure</parameter> character is escaped inside
a field by doubling it; however, the <parameter>escape</parameter>
character can be used as an alternative. So for the default parameter
values <literal>""</literal> and <literal>\"</literal> have the same
meaning. Other than allowing to escape the
<parameter>enclosure</parameter> character the
<parameter>escape</parameter> character has no special meaning; it isn't
even meant to escape itself.
Inside an <parameter>enclosure</parameter>, the <parameter>enclosure</parameter> character can always be <parameter>escaped</parameter> by doubling it,
resulting in a single <parameter>enclosure</parameter> character in the parsed result.
The <parameter>escaped</parameter> character works differently:
If it is followed by an <parameter>enclosure</parameter> character then that <parameter>enclosure</parameter> character will not be treated as one,
however the <parameter>escaped</parameter> character itself remains. So for the default parameters, <literal>""</literal>
inside an <parameter>enclosure</parameter> will be parsed into <literal>",</literal> while <literal>\"</literal> inside an
<parameter>enclosure</parameter> will be parsed into <literal>\"</literal>.
</simpara>
</note>
</warning>
<warning>
<simpara>
As of PHP 8.4.0, depending on the default value of