Emojis in Post

Started by Gluz, June 13, 2015, 04:56:14 AM

Previous topic - Next topic

Gluz

Some of my users, use their phones to post, and some of them start to put emojis in their posts, but find that they can't preview the post, it triggers this error:

QuoteThe message body was left empty.

No matter the lenght of the text, when some emoji is inserted just shows that error. But if they hit the "Post" button, it stores in the database and it shows in the post as well, only the preview thing isn't working for the emojis, that happens to be an unicode character now supported by many browsers(Safari shows them as they shows in Whatsapp, the others I tested just show a plain vector) as showed next:

😄(If viewed in Apple devices it shows different than In the PC, and I supose that Android will show their set of emojis as well, and I know that this is a simple happy face that is in the smilies, but some people just want to use emojis instead of the smilies even when I told them that emojis aren't supported in the forum)

It shows in the post but can't view the preview. To replicate the issue(my mobile just sucks and is a pain in the ass post something here from it) I'm currently using this in Firefox, as seems to have most of the emojis in the emoji keyboard of the mobile devices, and have the unicode and a shortcut that many sites(github included) have been integrated to display them.


Is there something that can be done to make the previews work with emojis? Rather fix the behavior or just not show them but all the other text in typed. I'm not searched through the code yet to see what happening when someone hit the "Preview" button.

Currently I'm running SMF 2.0.10, some mods and tweaks but no one that touches the editor of SMF.

And looking forward, maybe this should be tested in 2.1 as well, because many users now use their phones to navigate in the forums.

Illori

Quote from: Gluz on June 13, 2015, 04:56:14 AM
Is there something that can be done to make the previews work with emojis? Rather fix the behavior or just not show them but all the other text in typed. I'm not searched through the code yet to see what happening when someone hit the "Preview" button.

as you pointed out each system has its own set of emojis, if the PC does not have a set it does not show. i dont think there really is a good way to fix this unless SMF ships with their own set which i dont see happening.

Gluz

Yep, that part I understand it, I'm making some test with a few jquery libs to add to SMF to display them as images, and is kind of interesting how that works(need some edits in the editor mainly), but that's another story.

My issue here is that the Post/database gets the data OK, it shows in the post, but the Preview is broken, it doesn't show any text when have a emoji(and I think that this will happen with some unicode characters as well, not common characters though).


PS: I just noticed that Chrome does not display the character in my first post, but Firefox and IE does.

Illori

then that part is a bug as only in 2.0.10 did they patch it so that emojis would not crash SMF. i guess they did not consider the preview as part that needed to be fixed.

also seems to be browser dependent if the emoji will show on the desktop... looked at this topic in firefox and i get an emoji where in opera 12.17 i get a blank box.

margarett

OK, so I gave this a spin.

If you have MySQL 5.5.3+ my advice is to change your tables and columns to utf8mb4 (you can find instructions on how to in that same page)

About Chrome and Opera: they share the same engine so it's likely they behave the same...
Don't know why but right now I can't see utf8mb4 characters anywhere...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Illori

Quote from: margarett on June 14, 2015, 04:31:09 PM
About Chrome and Opera: they share the same engine so it's likely they behave the same...
Don't know why but right now I can't see utf8mb4 characters anywhere...

newer opera does, but not older opera ;)

which browser do you not see the character in?

Gluz

My database is in utf8/utf8_general_ci and it does store the data that's not a problem (in the test forum I've already converted to utf8mb4 to test this as well), my issue is that the Post Preview is not working when the text have an emoji.

To view this, quote my first post and hit Preview, you will get the error of Message Body empty, but if you delete the emoji character(the one between size BBCode) it works.

I just take a look at the source files, and I can't figure out where the preview is generated, what functions parses the text introduced in the textarea or how it's generated, just found where the error is triggered in Post.php:
if (htmltrim__recursive(htmlspecialchars__recursive($_REQUEST['message'])) == '')
$context['post_error']['no_message'] = true;


Any thoughts on what could cause the Preview to break but not the actual data storage?

PS: maybe the title of this thread should be "Emojis in Post break Post Preview" as this is my actual issue.

margarett

No idea why but I can't view any utf8mb4 character in my computer today. Very odd.

I do remember testing that (when we were preparing 2.0.10) and I think that it worked. It is possible that it's a browser-related problem (or not, I need to test when my computer feels like showing these characters :P )
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: