nette / utils

🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
https://doc.nette.org/utils
Other
1.98k stars 147 forks source link

German umlauts are converted incorrectly with "toAscii" (webalize) method #239

Closed Zrnik closed 3 years ago

Zrnik commented 3 years ago

Version: i think every version

Bug Description

Method toAscii (and thus webalize) is incorrectly converting german umlauts.

Reproduce

<?php declare(strict_types=1);

include __DIR__ . '/src/Utils/StaticClass.php';
include __DIR__ . '/src/Utils/Callback.php';
include __DIR__ . '/src/Utils/Strings.php';

$ok = "✔️";
$err = "❌";

$CorrectConversions = [
    "Jägermeister" => "jaegermeister",
    "Würth" => "wuerth",
    "Löwenbräu" => "loewenbraeu",
    "Straße" => "strasse"
];

foreach ($CorrectConversions as $toConvert => $correctConversion) {
    $converted = \Nette\Utils\Strings::webalize($toConvert);
    $isCorrect = $converted === $correctConversion;
    echo $toConvert . " (".$correctConversion.") => " . ($isCorrect ? $ok : $err) . " " . $converted . PHP_EOL;
}

Result:

Jägermeister (jaegermeister) => ❌ jagermeister
Würth (wuerth) => ❌ wurth
Löwenbräu (loewenbraeu) => ❌ lowenbrau
Straße (strasse) => ✔️ strasse

Expected Behavior

Jägermeister (jaegermeister) => ✔️ jaegermeister
Würth (wuerth) => ✔️ wuerth
Löwenbräu (loewenbraeu) => ✔️ loewenbraeu
Straße (strasse) => ✔️ strasse
Zrnik commented 3 years ago

❤️