PhpSpreadsheet/docs/topics
oleibman e768cb0f19
CSV - Guess Encoding, Handle Null-string Escape (#1717)
* CSV - Guess Encoding, Handle Null-string Escape

This is in response to issue #1647 (detect CSV character encoding).
First, my tests with mb_detect_encoding indicate that it doesn't work
well enough; regardless, users can always do that on their own
if they deem it useful.
Rolling my own is also troublesome, but I can at least:
a. Check for BOM (UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE).
b. Do some heuristic tests for each of the above encodings.
c. Fallback to a user-specified encoding (default CP1252)
  if a and b don't yield result.
I think this is probably useful enough to include, and relatively
easy to expand if other potential encodings should be considered.

Starting with PHP7.4, fgetcsv allows specification of null string as
escape character in fgetcsv. This is a much better choice than the PHP
(and PhpSpreadsheet) default of backslash in that it handles the file
in the same manner as Excel does. There is one statement in Reader/CSV
which would be adversely affected if the caller so specified (building
a regular expression under the assumption that escape character is
a single character). Fix that statement appropriately and add tests.
2020-12-25 17:47:29 +01:00
..
images Update documentation with composer instructions 2017-03-13 12:30:26 +09:00
accessing-cells.md Apply Column and Row Styles to Existing Cells (#1721) 2020-12-10 18:19:56 +01:00
architecture.md Code highlight in docs for PhpStorm 2020-05-31 22:44:25 +09:00
autofilters.md Code highlight in docs for PhpStorm 2020-05-31 22:44:25 +09:00
calculation-engine.md Updating a misspelling of a function name. (#1695) 2020-11-01 12:05:04 +01:00
creating-spreadsheet.md Code highlight in docs for PhpStorm 2020-05-31 22:44:25 +09:00
defined-names.md Named formula implementation, and improved handling of Defined Names generally (#1535) 2020-07-26 12:00:06 +02:00
file-formats.md Prefer https:// URLs when available in docs & comments 2018-10-28 13:55:00 +11:00
memory_saving.md Code highlight in docs for PhpStorm 2020-05-31 22:44:25 +09:00
migration-from-PHPExcel.md Code highlight in docs for PhpStorm 2020-05-31 22:44:25 +09:00
reading-and-writing-to-file.md CSV - Guess Encoding, Handle Null-string Escape (#1717) 2020-12-25 17:47:29 +01:00
reading-files.md Code highlight in docs for PhpStorm 2020-05-31 22:44:25 +09:00
recipes.md Add exportArray Method for Styles (#1580) 2020-10-26 20:56:24 +01:00
settings.md WEBSERVICE is HTTP client agnostic 2020-07-19 11:33:01 +09:00
worksheets.md Code highlight in docs for PhpStorm 2020-05-31 22:44:25 +09:00