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

Add support for emoji 🙏 #1627

Closed
connor-baer opened this issue Apr 12, 2017 · 6 comments
Closed

Add support for emoji 🙏 #1627

connor-baer opened this issue Apr 12, 2017 · 6 comments
Assignees
Labels

Comments

@connor-baer
Copy link

connor-baer commented Apr 12, 2017

Description

Craft 3 doesn't seem to support emoji in any field that I tried (plain text, rich text, category). 😿

I found this StackExchange answer from @takobell where he states that Craft will automatically HTML encode emoji in a rich text field. This doesn't seem to be the case. His answer also mentions the possibility to set the database charset and collation to utf8mb4 and utf8mb4_unicode_ci. Will this work with Craft 3? Is it advisable to do?

Steps to reproduce

  1. 😎 Enter a cool emoji into a field.
  2. 💾 Save the entry.
  3. ⚠️ Receive an error message like this one:
Internal Server Error

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x95\x93' for column 'title' at row 1 The SQL being executed was: UPDATE `craft_content` SET `elementId`=217, `siteId`=1, `title`='New Website 🍻', `field_featured`=1, `field_passphrase`='', `dateUpdated`='2017-04-12 18:36:57' WHERE `id`='348'

Additional info

  • Craft version: Craft 3.0.0-beta.10
  • PHP version: 7.1.4
  • Database driver & version: MySQL 5.7.17
@brandonkelly brandonkelly self-assigned this Apr 12, 2017
@brandonkelly brandonkelly added enhancement improvements to existing features bug and removed enhancement improvements to existing features labels Apr 12, 2017
@brandonkelly
Copy link
Member

Fixed for Craft 3 / MySQL. Not an issue on PostgreSQL, though, and I didn’t get any errors in Craft 2.

@lazlo-bonin
Copy link

Is this fixed? I'm still getting the same error, regardless of my database charset and collation.

Craft 3.0.21.

@brandonkelly
Copy link
Member

@lazlo-bonin We’ve fixed it as best as we can for MySQL using the LitEmoji library, but it only supports a subset of Emoji. So it depends.

@tomkiss
Copy link

tomkiss commented Oct 13, 2018

Hey @brandonkelly,
I’m finally starting to switch over to Craft3 - just wanted to note that I am seeing this issue.
The circumstances are a little different - I have an emoji in a twig template, which is cached by craft on first load, which then saves it and breaks.

Sorry if this is the wrong place to post this, I can see there are a bunch of posted issues around this, just didn’t want to start a new one.

@brandonkelly
Copy link
Member

@tomkiss How is the template getting cached? Craft’s {% cache %} tag automatically encodes all 4+ byte characters, so you shouldn’t have any emoji-related problems with that.

if (Craft::$app->getDb()->getIsMysql()) {
// Encode any 4-byte UTF-8 characters
$body = StringHelper::encodeMb4($body);
}

@tomkiss
Copy link

tomkiss commented Oct 22, 2018

Thanks Brandon,
I did a little more digging and was able to resolve the issue by flushing out the craft_templatecaches table.
Up and running after that! Perhaps it's something that can be done as part of the upgrade process if that's not too aggressive.

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

4 participants