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
{{ message }}
Repository navigation
Configure export engines at construction and normalize encodings - #41
Non-UTF-8 input cannot pass through DataSheet's JSON storage. Engine settings can also be changed after construction, including after export processing has begun.
This is intentionally a breaking change. DataSheet normalizes input to UTF-8. CSV output uses an encoding enum. Engine options are set at construction.
Migration Notes
CSV output encoding
Replace CsvEngine::UTF8, UTF16BE, UTF16LE, UTF32BE, and UTF32LE with the matching Quorum\Exporter\Engines\Csv\Encoding cases. The output encoding argument no longer accepts strings.
Replace generic CsvEngine::UTF16 and CsvEngine::UTF32 with an explicit big-endian or little-endian case. Output no longer depends on the host machine's byte order.
Other output encodings are no longer supported. Choose one of the five enum cases.
Input encoding
Move inputEncoding from the CsvEngine constructor to the DataSheet constructor. It accepts an Encoding case or an mbstring encoding name. UTF-8 remains the default.
Each sheet converts string values to UTF-8 when rows are added. Iteration and every export engine receive the converted values. Other scalar values are converted to strings. Array keys must be valid UTF-8.
Review positional CsvEngine constructor calls. The fourth argument is now bomEnabled, the fifth is multiSheetStrategy, and the sixth is tmpDir.
Set these options in the constructor. The setters and byte order mark toggle have been removed.
Previous call
Constructor argument
$csv->setDelimiter($value)
delimiter: $value
$csv->setEnclosure($value)
enclosure: $value
$csv->setMultiSheetStrategy($value)
multiSheetStrategy: $value
$csv->disableBom()
bomEnabled: false
$csv->disableBom(false)
bomEnabled: true
$csv->setTmpDir($path)
tmpDir: $path
$spreadsheet->setCreatedTime($timestamp)
createdTime: new DateTimeImmutable('@' . $timestamp)
Delimiter and enclosure values must now be a single ASCII byte. The CSV tmpDir option checks that the directory exists before ZIP export. It does not select where temporary streams are stored.
The SpreadsheetML createdTime argument accepts DateTimeInterface instead of an integer. Its time zone is preserved. Null uses the current time when exporting. Pass null for the old null-or-zero behavior. A date object at Unix timestamp zero now represents the Unix epoch. The @ constructor syntax uses UTC; set the time zone explicitly if the previous local-time representation is needed.
Subclasses must review the removed protected encoding setters and isLittleEndian() method. The CSV output encoding property now holds an Encoding case. The CSV input encoding property has been removed. SpreadsheetML's creation time property now holds a date object or null.
Validation
On PHP 8.5, make lint test and the MDDoc dry run pass. PHPUnit passes 40 tests with 94 assertions. Tests cover explicit output encodings, constructor options, date objects, Latin-1 and UTF-16 input, mixed scalar values, CSV quoting, SpreadsheetML output, and custom sheet iterators.
donatj
changed the title
Add enum for CSV multi-sheet strategies
Use an enum for CSV multi-sheet strategies
Nov 10, 2026
donatj
changed the title
Use an enum for CSV multi-sheet strategies
Use enums for CSV strategies and encodings
Nov 10, 2026
donatj
changed the title
Use enums for CSV strategies and encodings
Rename the CSV engine and use enums for its options
Nov 10, 2026
donatj
changed the title
Rename the CSV engine and use enums for its options
Use enums for CSV strategies and encodings
Nov 10, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The conversion pipeline corrupts accepted non-ASCII CSV delimiters and enclosures, while the new test accepts a BOM/byte-order mismatch that breaks decoding on little-endian hosts.
This PR introduces typed CSV options and binary-safe sheet storage, allowing non-UTF-8 input to be converted before CSV formatting. It intentionally breaks the previous string-based API.
Changes:
Replace strategy and encoding constants with enums and add constructor options for strategy and byte order marks.
Preserve input bytes in DataSheet and convert values to UTF-8 before CSV formatting.
Update integration tests, the UTF-8 fixture, examples, and generated documentation.
File
Description
test/Integration/fixtures/basic-csv-UTF-8.csv
Add the default UTF-8 byte order mark.
test/Integration/DataSheetTest.php
Test binary-safe row round trips.
test/Integration/CsvIntegrationTest.php
Cover enums, encodings, byte order marks, and export strategies.
src/Engines/CsvEngine.php
Adopt typed options and per-value input conversion.
src/Engines/Csv/MultiSheetStrategy.php
Define concatenation and ZIP strategies.
src/Engines/Csv/Encoding.php
Define seven supported output encodings.
src/DataSheet.php
Replace JSON storage with binary-safe serialization.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
UTF-16LE input decoding corrupts numeric values during CSV export because original scalar types are lost, requiring type preservation and a mixed text-and-number regression test.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Avoid decoding numeric values as UTF-16LE
src/Engines/CsvEngine.php:126
With inputEncoding: Encoding::UTF16LE, a row containing encoded text and the integer 42 exports the number as ㈴: DataSheet::normalizeValue() first casts it to ASCII "42", which this line then decodes as UTF-16LE. Preserve original scalar types or equivalent metadata through storage so input decoding applies only to original strings. Add a regression test mixing multibyte text with numeric values.
Fixed the mixed-type UTF-16LE input issue from Copilot's latest review in dcb0613. DataSheet retains the original scalar types for CSV conversion while its public iterator continues to return strings. The regression test covers encoded text, integers, floats, booleans, null, and an encoded numeric string.
donatj
changed the title
Use an encoding enum and support non-UTF-8 CSV input
Configure export engines at construction and normalize encodings
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Non-UTF-8 input cannot pass through DataSheet's JSON storage. Engine settings can also be changed after construction, including after export processing has begun.
This is intentionally a breaking change. DataSheet normalizes input to UTF-8. CSV output uses an encoding enum. Engine options are set at construction.
Migration Notes
CSV output encoding
CsvEngine::UTF8,UTF16BE,UTF16LE,UTF32BE, andUTF32LEwith the matchingQuorum\Exporter\Engines\Csv\Encodingcases. The output encoding argument no longer accepts strings.CsvEngine::UTF16andCsvEngine::UTF32with an explicit big-endian or little-endian case. Output no longer depends on the host machine's byte order.Input encoding
inputEncodingfrom theCsvEngineconstructor to theDataSheetconstructor. It accepts anEncodingcase or an mbstring encoding name. UTF-8 remains the default.CsvEngineconstructor calls. The fourth argument is nowbomEnabled, the fifth ismultiSheetStrategy, and the sixth istmpDir.Engine configuration
Set these options in the constructor. The setters and byte order mark toggle have been removed.
$csv->setDelimiter($value)delimiter: $value$csv->setEnclosure($value)enclosure: $value$csv->setMultiSheetStrategy($value)multiSheetStrategy: $value$csv->disableBom()bomEnabled: false$csv->disableBom(false)bomEnabled: true$csv->setTmpDir($path)tmpDir: $path$spreadsheet->setCreatedTime($timestamp)createdTime: new DateTimeImmutable('@' . $timestamp)Delimiter and enclosure values must now be a single ASCII byte. The CSV
tmpDiroption checks that the directory exists before ZIP export. It does not select where temporary streams are stored.The SpreadsheetML
createdTimeargument acceptsDateTimeInterfaceinstead of an integer. Its time zone is preserved. Null uses the current time when exporting. Pass null for the old null-or-zero behavior. A date object at Unix timestamp zero now represents the Unix epoch. The@constructor syntax uses UTC; set the time zone explicitly if the previous local-time representation is needed.Subclasses must review the removed protected encoding setters and
isLittleEndian()method. The CSV output encoding property now holds anEncodingcase. The CSV input encoding property has been removed. SpreadsheetML's creation time property now holds a date object or null.Validation
On PHP 8.5,
make lint testand the MDDoc dry run pass. PHPUnit passes 40 tests with 94 assertions. Tests cover explicit output encodings, constructor options, date objects, Latin-1 and UTF-16 input, mixed scalar values, CSV quoting, SpreadsheetML output, and custom sheet iterators.