Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[String] AsciiSlugger : iconv(): Wrong charset, conversion from UTF-8' to ASCII//IGNORE//TRANSLIT' is not allowed #37213

Copy link
Copy link
Closed
@gnutix

Description

@gnutix
Issue body actions

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

Stacktrace: image

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

  1. Remove the characters that would trigger this error (preemptively or by catching it)
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.