Open tiomanisland opened 5 years ago
:heart: should be : heart : but github replaced it with icon
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.
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.
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
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.
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.
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',
Demo works fine but on Submit form (to .php) I am not getting tags like :heart: 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 :heart: and it looks lovely --> (form submit) --> php then I would save this to DB later I would read from db and replace :heart: with correct emoji image
Can someone help?