From 4fcfa83e7e3ad362c48eb5477968e437e53cf2be Mon Sep 17 00:00:00 2001 From: Stephan Kergomard Date: Mon, 11 Nov 2024 18:44:25 +0100 Subject: [PATCH] Excel: Include Noncharacters from Above BOM --- Services/Excel/classes/class.ilExcel.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Services/Excel/classes/class.ilExcel.php b/Services/Excel/classes/class.ilExcel.php index f7196a646e0a..c18ad81c2327 100644 --- a/Services/Excel/classes/class.ilExcel.php +++ b/Services/Excel/classes/class.ilExcel.php @@ -37,7 +37,26 @@ class ilExcel public const FORMAT_BIFF = "Xls"; protected string $format; - private string $noncharacters = '[\uFFFE-\uFFFF\uFDD0-\uFDEF]'; + private array $noncharacters = [ + '\x{FFFE}-\x{FFFF}', + '\x{1FFFE}-\x{1FFFF}', + '\x{2FFFE}-\x{2FFFF}', + '\x{3FFFE}-\x{3FFFF}', + '\x{4FFFE}-\x{4FFFF}', + '\x{5FFFE}-\x{5FFFF}', + '\x{6FFFE}-\x{6FFFF}', + '\x{7FFFE}-\x{7FFFF}', + '\x{8FFFE}-\x{8FFFF}', + '\x{9FFFE}-\x{9FFFF}', + '\x{AFFFE}-\x{AFFFF}', + '\x{BFFFE}-\x{BFFFF}', + '\x{CFFFE}-\x{CFFFF}', + '\x{DFFFE}-\x{DFFFF}', + '\x{EFFFE}-\x{EFFFF}', + '\x{FFFFE}-\x{FFFFF}', + '\x{10FFFE}-\x{10FFFF}', + '\x{FDD0}-\x{FDEF}' + ]; protected ilLanguage $lng; protected Spreadsheet $workbook; @@ -570,6 +589,6 @@ public function mergeCells(string $coordinatesRange): void private function cleanupNonCharachters(string $string): string { - return mb_ereg_replace($this->noncharacters, '', $string); + return mb_ereg_replace('[' . implode('', $this->noncharacters) . ']', '', $string); } }