Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[String] Add a method to stripg emojis from strings #58003

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

Closed
MolloKhan opened this issue Aug 13, 2024 · 6 comments
Closed

[String] Add a method to stripg emojis from strings #58003

MolloKhan opened this issue Aug 13, 2024 · 6 comments
Labels

Comments

@MolloKhan
Copy link
Contributor

Description

Following up on #48853 and #48850 here's another use case that may help to push this feature forward.

In SymfonyCasts, we use a third-party service to generate video captions. It requires sending the script file which may contain emojis and that causes trouble. So, I need to remove them before sending the file to the third-party service

Example

No response

@stof
Copy link
Member

stof commented Aug 13, 2024

Stripping emojis from a string is already supported by the EmojiTransliterator:

use Symfony\Component\Emoji\EmojiTransliterator;

$emojiStrippingTransliterator = EmojiTransliterator::create('emoji-strip');

$string = 'my input string which may have emojis';

$stringWithoutEmoji = $emojiStrippingTransliterator->transliterate($string);

So this can be done even if symfony/string does not have a method doing that for you.

@stof
Copy link
Member

stof commented Aug 13, 2024

And btw, the same question applies for this use case than for previous ones: is the issue in the third-party services related to not accepting emojis or is it about not accepting multi-bytes UTF-8 codepoints (maybe only the ones using 4 bytes) ?

@MolloKhan
Copy link
Contributor Author

And btw, the same question applies for this use case than for previous ones: is the issue in the third-party services related to not accepting emojis or is it about not accepting multi-bytes UTF-8 codepoints (maybe only the ones using 4 bytes) ?

I'm not certain about it. They are not that explicit

@stof
Copy link
Member

stof commented Aug 13, 2024

@MolloKhan the question is what do they reject (and why). See for instance #48853 (comment): the broken utf8 type in MySQL (which uses utf8mb3) rejects all 4-bytes characters, which will reject most emojis (but not all) but also other things.

Rejecting only emojis is actually much more explicit than rejecting 4-bytes codepoints.

@MolloKhan
Copy link
Contributor Author

Yea, but they don't say. The API call just fails with "invalid data". I discovered that removing all emojis fixes the issue. Anyway, I was not aware that the Symfony Emoji component already has this feature, so if you don't find a real value add a shortcut to it in the String component, I think we can close this request

@stof
Copy link
Member

stof commented Aug 13, 2024

Well, both issues you linked were saying that they leverage the EmojiTransliterator to implement the stripping.

I will close this issue as I don't think the use case mentioned here is sufficient to revisit our decision to reject the shortcut in the String component.

@stof stof closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants