diff --git a/src/CodePoint.php b/src/CodePoint.php index 06a172c..86c922e 100644 --- a/src/CodePoint.php +++ b/src/CodePoint.php @@ -103,9 +103,6 @@ public function toHtmlEntity(): string public function toXmlEntity(): string { - return htmlentities( - $this->toCharacter(), - ENT_XML1 | ENT_QUOTES | ENT_SUBSTITUTE, - ); + return '&#x' . dechex($this->decimal) . ';'; } } diff --git a/test/Unit/CodePointTest.php b/test/Unit/CodePointTest.php index e1f0f64..ed28bf2 100644 --- a/test/Unit/CodePointTest.php +++ b/test/Unit/CodePointTest.php @@ -145,6 +145,10 @@ public function testItCanInstantiateOfXmlEntity( string $htmlEntity, string $xmlEntity ): void { + if ($xmlEntity === '�') { + $this->markTestSkipped('XML does not have NULL value'); + } + $codePoint = CodePoint::ofXmlEntity($xmlEntity); $this->assertSame( @@ -253,18 +257,18 @@ public function testItCannotInstantiateOfXmlEntityWithMoreThanOneCharacter(): vo public static function provideUnicodeMap(): array { return [ - ["\x00", 0, 'U+0000', "\x00", "\x00"], - ['􏿿', 1114111, 'U+10FFFF', '􏿿', '􏿿'], - [' ', 32, 'U+0020', ' ', ' '], - ['A', 65, 'U+0041', 'A', 'A'], - [' ', 160, 'U+00A0', ' ', ' '], - ['ÿ', 255, 'U+00FF', 'ÿ', 'ÿ'], - ['Ā', 256, 'U+0100', 'Ā', 'Ā'], - ['ſ', 383, 'U+017F', 'ſ', 'ſ'], - ['€', 8364, 'U+20AC', '€', '€'], - ['⚙', 9881, 'U+2699', '⚙', '⚙'], - ['👨', 128104, 'U+1F468', '👨', '👨'], - ['�', 65533, 'U+FFFD', '�', '�'], + ["\x00", 0, 'U+0000', "\x00", '�'], + ['􏿿', 1114111, 'U+10FFFF', '􏿿', '􏿿'], + [' ', 32, 'U+0020', ' ', ' '], + ['A', 65, 'U+0041', 'A', 'A'], + [' ', 160, 'U+00A0', ' ', ' '], + ['ÿ', 255, 'U+00FF', 'ÿ', 'ÿ'], + ['Ā', 256, 'U+0100', 'Ā', 'Ā'], + ['ſ', 383, 'U+017F', 'ſ', 'ſ'], + ['€', 8364, 'U+20AC', '€', '€'], + ['⚙', 9881, 'U+2699', '⚙', '⚙'], + ['👨', 128104, 'U+1F468', '👨', '👨'], + ['�', 65533, 'U+FFFD', '�', '�'], ]; } }