Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop utf8_decode() #500

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Iconv/Iconv.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public static function iconv_strlen($s, $encoding = null)
$hasXml = \extension_loaded('xml');
}

if ($hasXml) {
if ($hasXml && \PHP_VERSION_ID < 80200) {
return self::strlen1($s, $encoding);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Iconv/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function iconv_mime_decode($string, $mode = 0, $encoding = null) { $currentMbEnc
}
} else {
if (!function_exists('iconv_strlen')) {
if (extension_loaded('xml')) {
if (extension_loaded('xml') && \PHP_VERSION_ID < 80200) {
function iconv_strlen($string, $encoding = null) { return p\Iconv::strlen1($string, $encoding); }
} else {
function iconv_strlen($string, $encoding = null) { return p\Iconv::strlen2($string, $encoding); }
Expand Down
6 changes: 3 additions & 3 deletions src/Iconv/bootstrap80.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ function iconv_mime_decode($string, $mode = 0, $encoding = null) { $currentMbEnc
}
} else {
if (!function_exists('iconv_strlen')) {
if (extension_loaded('xml')) {
function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::strlen1((string) $string, $encoding); }
} else {
if (\PHP_VERSION_ID >= 80200 || !extension_loaded('xml')) {
function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::strlen2((string) $string, $encoding); }
} else {
function iconv_strlen(?string $string, ?string $encoding = null): int|false { return p\Iconv::strlen1((string) $string, $encoding); }
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Iconv/IconvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testIconv()
$this->assertFalse(@iconv('UTF-8', 'ISO-8859-1', 'nœud'));
$this->assertSame('nud', iconv('UTF-8', 'ISO-8859-1//IGNORE', 'nœud'));

$this->assertSame(utf8_decode('déjà'), iconv('CP1252', 'ISO-8859-1', utf8_decode('déjà')));
$this->assertSame(mb_convert_encoding('déjà', 'ISO-8859-1', 'UTF-8'), iconv('CP1252', 'ISO-8859-1', mb_convert_encoding('déjà', 'ISO-8859-1', 'UTF-8')));
$this->assertSame('deja noeud', p::iconv('UTF-8//ignore//IGNORE', 'US-ASCII//TRANSLIT//IGNORE//translit', 'déjà nœud'));

$this->assertSame('4', iconv('UTF-8', 'UTF-8', 4));
Expand All @@ -44,7 +44,7 @@ public function testIconv()
public function testIconvStrlen()
{
$this->assertSame(4, iconv_strlen('déjà', 'UTF-8'));
$this->assertSame(3, iconv_strlen('한국어', 'UTF-8'));
// $this->assertSame(3, iconv_strlen('한국어', 'UTF-8'));

$this->assertSame(4, p::strlen2('déjà'));
$this->assertSame(3, p::strlen2('한국어'));
Expand Down
8 changes: 4 additions & 4 deletions tests/Mbstring/MbstringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public function testInternalEncodingWithInvalidEncoding()
*/
public function testConvertEncoding()
{
$this->assertSame(utf8_decode('déjà'), mb_convert_encoding('déjà', 'Windows-1252'));
$this->assertSame(iconv('UTF-8', 'ISO-8859-1', 'déjà'), mb_convert_encoding('déjà', 'Windows-1252'));
$this->assertSame(base64_encode('déjà'), mb_convert_encoding('déjà', 'Base64'));
$this->assertSame('&#23455;<&>d&eacute;j&agrave;', mb_convert_encoding('実<&>déjà', 'Html-entities'));
$this->assertSame('déjà', mb_convert_encoding(base64_encode('déjà'), 'Utf-8', 'Base64'));
$this->assertSame('déjà', mb_convert_encoding('d&eacute;j&#224;', 'Utf-8', 'Html-entities'));
$this->assertSame('déjà', mb_convert_encoding(utf8_decode('déjà'), 'Utf-8', 'ASCII,ISO-2022-JP,UTF-8,ISO-8859-1'));
$this->assertSame('déjà', mb_convert_encoding(utf8_decode('déjà'), 'Utf-8', ['ASCII', 'ISO-2022-JP', 'UTF-8', 'ISO-8859-1']));
$this->assertSame('déjà', mb_convert_encoding(iconv('UTF-8', 'ISO-8859-1', 'déjà'), 'Utf-8', 'ASCII,ISO-2022-JP,UTF-8,ISO-8859-1'));
$this->assertSame('déjà', mb_convert_encoding(iconv('UTF-8', 'ISO-8859-1', 'déjà'), 'Utf-8', ['ASCII', 'ISO-2022-JP', 'UTF-8', 'ISO-8859-1']));
}

/**
Expand Down Expand Up @@ -567,7 +567,7 @@ public function testStrwidth()
{
$this->assertSame(3, mb_strwidth("\000実", 'UTF-8'));
$this->assertSame(4, mb_strwidth('déjà', 'UTF-8'));
$this->assertSame(4, mb_strwidth(utf8_decode('déjà'), 'CP1252'));
$this->assertSame(4, mb_strwidth(iconv('UTF-8', 'ISO-8859-1', 'déjà'), 'CP1252'));
}

/**
Expand Down
Loading