diff --git a/Linse/Iso5426Converter.php b/Linse/Iso5426Converter.php index 6dd34ed0f15d32ebda3f8a9fe7669f6a32842864..d1f96c593911c9fc8f4cb14e6a1686b944876de5 100644 --- a/Linse/Iso5426Converter.php +++ b/Linse/Iso5426Converter.php @@ -391,7 +391,7 @@ class Linse_Iso5426Converter { $combined_chars = $c1 * 256 + $c2; if (array_key_exists($combined_chars, $combined)) - return chr($combined[$combined_chars]); + return html_entity_decode('&#'. $combined[$combined_chars] . ';', ENT_NOQUOTES, 'UTF-8'); $single = [0xe1 => 'Æ', 0xe2 => 'Ä', diff --git a/tests/Linse/Iso5426ConverterTest.php b/tests/Linse/Iso5426ConverterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b7e3b60ac64fac7947c6ba977552fa8378f2cfeb --- /dev/null +++ b/tests/Linse/Iso5426ConverterTest.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2012-2016, Agence Française Informatique (AFI). All rights reserved. + * + * LINSE is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * LINSE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with LINSE; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Linse_Iso5426ConverterTest extends PHPUnit_Framework_TestCase{ + /** @test */ + public function shouldConvertEacute() { + $this->assertEquals('é', (new Linse_Iso5426Converter())->toUnicode(chr(0xc2).chr(0x65))); + } +} \ No newline at end of file diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ded7486a45c808b0cb933f7ca486f4e51aa16198..a2969951df5a92153498c4a239f0171c251b693b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -19,4 +19,5 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once __DIR__ . '/../Linse.php'; \ No newline at end of file +require_once __DIR__ . '/../Linse.php'; +require_once __DIR__ . '/../Linse/Iso5426Converter.php'; \ No newline at end of file