Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV documentation functions need a clearer warning about the proprietary escape mechanism. #3086

Closed
RichardNeill opened this issue Jan 9, 2024 · 5 comments
Labels
good first issue Good for newcomers

Comments

@RichardNeill
Copy link

RichardNeill commented Jan 9, 2024

A lot of people, myself included, expected the 3 CSV-functions:

  • fputcsv()
  • fgetcsv()
  • str_getcsv()

to work in the most consistent/standard/obvious way when called without the optional parameters.
But it doesn't! The default is backwards - if you want to be RFC-4180 compliant, you need to explicitly set the 5th option to be the empty string. This is unusual for PHP: normally optional parameters can be omitted unless you want to do something unusual. This has bitten people repeatedly, even leading to an RFC: https://wiki.php.net/rfc/kill-csv-escaping

So, my suggestion is that each of these 3 has a clearly worded "Note" added, namely:

The default-value of the proprietary-escape mechanism is "", which is inconsistent with the most common standard
for CSV files, RFC-4180. For compatibility, it is recommended that you always explicitly specify the 5th parameter,
'escape', as "", i.e. the empty string.

Thanks.

@Girgias
Copy link
Member

Girgias commented Jan 10, 2024

Could you provide a PR?

Also the RFC has only been enacted with step 1 none of the other steps have been taken.

@Girgias Girgias added the good first issue Good for newcomers label Jan 10, 2024
@kamil-tekiela
Copy link
Member

Has this been completed?

@Girgias
Copy link
Member

Girgias commented Nov 19, 2024

Probably will be with #4093

@jimwins
Copy link
Member

jimwins commented Nov 19, 2024

Already was with #3765, I thought.

@Girgias
Copy link
Member

Girgias commented Nov 21, 2024

Fixed in more than one way.

@Girgias Girgias closed this as completed Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants