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

Force to EncloseField won't remove control characters since v9.7 #422

Closed
6 tasks done
patriziotomato opened this issue Apr 16, 2021 · 5 comments
Closed
6 tasks done
Assignees
Labels

Comments

@patriziotomato
Copy link

Bug Report

(Fill in the relevant information below to help triage your issue.)

Information Description
Version v9.7.0
PHP version v7.4
OS Platform Ubuntu 20.04

Summary

Forcing enclosures will not remove the "magic character"

Standalone code, or other way to reproduce the problem

Using the example leads to a CSV that still contains the control characters

$records = [
        ['Year', 'Make', 'Model', 'Description', 'Price'],
        [1997, 'Ford', 'E350', 'ac,abs,moon', '3000.00'],
        [1999, 'Chevy', 'Venture "Extended Edition"', null, '4900.00'],
        [1999, 'Chevy', 'Venture "Extended Edition, Very Large"', null, '5000.00'],
        [1996, 'Jeep', 'Grand Cherokee', 'MUST SELL!
        air, moon roof, loaded', '4799.00'],
    ];

    $writer = Writer::createFromPath(__DIR__.'/../storage/app/test.csv', 'w+');
    $writer->setDelimiter('|');
    EncloseField::addTo($writer, "\t\x1f");
    $writer->insertAll($records);

Expected result

"Year"|"Make"|"Model"|"Description"|"Price"
"1997"|"Ford"|"E350"|"ac,abs,moon"|"3000.00"
"1999"|"Chevy"|"Venture ""Extended Edition"""|""|"4900.00"
"1999"|"Chevy"|"Venture ""Extended Edition, Very Large"""|""|"5000.00"
"1996"|"Jeep"|"Grand Cherokee"|"MUST SELL!

Actual result

"	�Year"|"	�Make"|"	�Model"|"	�Description"|"	�Price"
"	�1997"|"	�Ford"|"	�E350"|"	�ac,abs,moon"|"	�3000.00"
"	�1999"|"	�Chevy"|"	�Venture ""Extended Edition"""|"	�"|"	�4900.00"
"	�1999"|"	�Chevy"|"	�Venture ""Extended Edition, Very Large"""|"	�"|"	�5000.00"
"	�1996"|"	�Jeep"|"	�Grand Cherokee"|"	�MUST SELL!
        air, moon roof, loaded"|"	�4799.00"

Checks before submitting

  • Be sure that there isn't already an issue about this. See: Issues list
  • Be sure that there isn't already a pull request about this. See: Pull requests
  • I have added every step to reproduce the bug.
  • If possible I added relevant code examples.
  • This issue is about 1 bug and nothing more.
  • The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
@nyamsprod nyamsprod self-assigned this Apr 17, 2021
@nyamsprod nyamsprod added the bug label Apr 17, 2021
@nyamsprod
Copy link
Member

fixed by #421

@patriziotomato
Copy link
Author

Any plans when to release this fix?

@nyamsprod
Copy link
Member

@patriziotomato should be released next week.

@patriziotomato
Copy link
Author

Thanks so much

@nyamsprod
Copy link
Member

9.7.1 has been released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants