We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
In #48396 we added an option to remove emojis from slugs:
use Symfony\Component\String\Slugger\AsciiSlugger; $slugger = new AsciiSlugger(); $slugger = $slugger->withEmoji('strip'); $slug = $slugger->slug('a 馃樅, 馃悎鈥嶁瑳, and a 馃');
I'd like to have this feature for strings too, not only slugs.
use function Symfony\Component\String\u; $string = u('馃樅 Lorem ipsum 馃悎鈥嶁瑳 dolor sit amet 馃')->stripEmojis()->toString(); // $string = ' Lorem ipsum dolor sit amet '
The text was updated successfully, but these errors were encountered:
How's the result in your example (a-and-a) different from what the slugger would produce?
a-and-a
Sorry, something went wrong.
@derrabus sorry! It was a copy+paste mistake. I've just updated the above example.
Thanks. Makes much more sense now. 馃槄
You can use the EmojiTransliterator for that.
I agree a shortcut method would still be useful, something like:
public function stripEmojis(): static { if (null === (self::$transliterators['emoji-strip'] ?? null)) { if (!class_exists(EmojiTransliterator::class)) { throw new \LogicException(sprintf('You cannot use the "%s()" method as the "symfony/intl" package is not installed. Try running "composer require symfony/intl".', __METHOD__)); } self::$transliterators['emoji-strip'] = EmojiTransliterator::create('emoji-strip'); } $str = clone $this; $str->string = self::$transliterators['emoji-strip']->transliterate($str->string); return $str; }
No branches or pull requests
Description
In #48396 we added an option to remove emojis from slugs:
I'd like to have this feature for strings too, not only slugs.
Example
The text was updated successfully, but these errors were encountered: