Closed
Description
Symfony version(s) affected: 5.0.7
Description
Passing extended UTF-8 characters into AsciSlugger->slug()
throws an error :
iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//IGNORE//TRANSLIT' is not allowed
How to reproduce
<?php
use Symfony\Component\String\Slugger\AsciiSlugger;
(new AsciiSlugger())->slug('😋');
I tried with an emoji 😋
and a braille character ⠚
, but probably that other characters have the same fate.
Possible Solutions
- Remove the characters that would trigger this error (preemptively or by catching it)
- Delegate the decision to the user by providing a callable to the slug method that would receive the "faulty" character as input :
use Symfony\Component\String\Slugger\AsciiSlugger;
$slug = (new AsciiSlugger())->slug('😋', '-', null, fn(string $c) => '');
var_dump($slug->toString()); // outputs ""
Additional context
Here's a list of characters to play with : https://www.utf8-chartable.de/unicode-utf8-table.pl