CODE/UNICODE and CHAR/UNICHAR

PhpSpreadsheet treats CODE and UNICODE as equivalent, likewise for CHAR and UNICHAR. They are, in fact, different. CODE and CHAR deal only with single-byte character sets (Windows-1252 or MacRoman), while UNICODE and UNICHAR deal with all of Unicode. This PR separates them. The existing unit test for CODE was, in many cases, applicable to UNICODE (for which there was no separate test). The tests are corrected for CODE, new tests are added, and a separate test for UNICODE is added. CHAR was mostly okay, new tests are added, and a separate test for UNICHAR is added.
This commit is contained in:
oleibman
2025-11-28 13:21:27 -08:00
parent cd4e71ed77
commit b243f2f4e5
13 changed files with 310 additions and 41 deletions
+22 -6
View File
@@ -2,6 +2,10 @@
declare(strict_types=1);
// Used to test both CODE and UNICODE.
// If expected result is array, 1st entry is for CODE, 2nd for UNICODE,
// and 3rd for CODE using MACROMAN.
return [
[
'#VALUE!',
@@ -48,28 +52,40 @@ return [
'£125.00',
],
[
12103,
[63, 12103],
'⽇',
],
[
0x153,
[156, 0x153, 207],
'œ',
],
[
0x192,
[131, 0x192, 196],
'ƒ',
],
[
0x2105,
[63, 0x2105],
'℅',
],
[
0x2211,
[63, 0x2211, 183],
'∑',
],
[
0x2020,
[134, 0x2020, 160],
'†',
],
[
[128, 8364, 63],
'€',
],
'non-ascii but same win-1252 vs unicode' => [
0xD0,
'Ð',
],
'ascii control character' => [
2,
"\x02",
],
'omitted argument' => ['exception'],
];