Files
PhpSpreadsheet/samples
oleibman 6edc552013 Writer Xls Handle Characters Outside Unicode BMP
Fix #642. Opened over 5 years ago, probably the oldest problem I've worked on. And https://github.com/PHPOffice/PHPExcel/issues/1320, opened a year before that. And https://github.com/SpartnerNL/Laravel-Excel/issues/1521.

Shared/StringHelper::UTF8toBIFF8UnicodeLong calculates incorrect length for strings when they contain characters outside Unicode BMP. Xls uses UTF-16 to encode its strings, and characters outside BMP require a surrogate pair to encode. PhpSpreadsheet (and PhpExcel before it) have been counting these as a single character, but Excel counts them as 2. Change to compute the length as half the number of bytes in the UTF-16 string, as Excel does.

A formal test is added, but it's a bit difficult to follow. So I aso added a non-BMP emoji to 27template.xls, which will cause it to be both read by Xls reader and written by Xls writer. This would previously have created a corrupt worksheet. The emoji is now handled correctly.
2023-08-31 09:46:02 +08:00
..
2023-04-02 20:05:43 +02:00
2021-11-24 09:12:46 +09:00
2023-06-15 00:48:31 +02:00
2021-11-24 09:12:46 +09:00
2022-11-09 22:55:31 +01:00