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

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

Closed
Zrnik opened this issue Nov 26, 2020 · 1 comment
Closed

Comments

@Zrnik
Copy link
Contributor

Zrnik commented Nov 26, 2020

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
Copy link
Contributor Author

Zrnik commented Dec 3, 2020

❤️

@Zrnik Zrnik closed this as completed Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant