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

How to save Emojis to MySQL #135

Open
tiomanisland opened this issue Apr 27, 2019 · 8 comments
Open

How to save Emojis to MySQL #135

tiomanisland opened this issue Apr 27, 2019 · 8 comments

Comments

@tiomanisland
Copy link

Demo works fine but on Submit form (to .php) I am not getting tags like ❤️ or :cars: but UTF emojis. I would like to use images (not UTF characters) and I don't know how to intercept form field with emoji-tags, save them and later display that post with images.

The demo simply replaces graphics emojis with UTF which is not what I need.

I want text box to return me:

Hello this is ❤️ and it looks lovely --> (form submit) --> php
then I would save this to DB
later I would read from db and replace ❤️ with correct emoji image

Can someone help?

@tiomanisland
Copy link
Author

❤️ should be : heart : but github replaced it with icon

@atakane
Copy link
Contributor

atakane commented Jun 18, 2019

Set your input field to accept Unicode by adding data-emoji-input="unicode" and set your MySQL fields as UTF-8 or UTF-16. Once you have done it, you could easily store the emojis and read them back as Unicode.

@antoiba86
Copy link

antoiba86 commented Jul 1, 2019

There are several ways to accomplish this.

Instead of send your input value, you can send the value of the input that is converted in the nuew input that has the class "emoji-wysiwyg-editor".
With this way, the editor will have the emojis converted as images.

Another way is getting the alt of the imgs of the emojis. For example, this will have the emoji : hearth : and you can saved it in database.
Later, you can convert them with a function from the emoji picker packages. I used the classes inside to create a function to solve this problem.

@umnibot
Copy link

umnibot commented May 20, 2020

To save the emojis into the db set the collation of the field to "utf8mb4_general_ci"

And to read them after a MySQL select, use

mysqli_set_charset($connection, 'utf8mb4');

right after the mysqli_connect (or whatever type of connection you are using).

Hope this helps someone

@dominicklee
Copy link

To convert the unicode versions back into the same images you see in the Picker, you can do:

window.emojiPicker.appendUnicodeAsImageToElement($("#yourDivID"),"😃")

Replace yourDivID with whatever the id of your element. You can also use getElementByID('yourDivID') instead.

@JSGund
Copy link

JSGund commented Jul 8, 2020

I want to get Unicode from input or textarea? but getting as "Hello 😃", so I can store the Unicode in the database and get it to convert to image using EmojiPicker methods.

@jlwegaba
Copy link

jlwegaba commented May 23, 2022

Am using ci4. At first i was getting ???? for the emojis in DB.
Changed in App-> Config -> Databases.php my DB settings to following and all worked well. Could see the emojis in DB.

'charset' => 'utf8mb4',
'DBCollat' => 'utf8mb4_bin',

@urgido
Copy link

urgido commented Jan 4, 2025

Am using ci4. At first i was getting ???? for the emojis in DB. Changed in App-> Config -> Databases.php my DB settings to following and all worked well. Could see the emojis in DB.

'charset' => 'utf8mb4', 'DBCollat' => 'utf8mb4_bin',

Save my life!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants