From 17c67fc39e6fe35d79961708192dfe49ca182126 Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@sandbox.pergame.net> Date: Mon, 4 Apr 2016 18:31:13 +0200 Subject: [PATCH] rel #41044 : converter under tests, fix combined chars hex to string conversion --- Linse/Iso5426Converter.php | 2 +- tests/Linse/Iso5426ConverterTest.php | 28 ++++++++++++++++++++++++++++ tests/bootstrap.php | 3 ++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/Linse/Iso5426ConverterTest.php diff --git a/Linse/Iso5426Converter.php b/Linse/Iso5426Converter.php index 6dd34ed..d1f96c5 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 0000000..b7e3b60 --- /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 ded7486..a296995 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 -- GitLab