Convert emoji to images

I have a private plugin that exports all posts without 'themeing', so the output is just html of the content (with the post subject as H1, and date/time as H2).

If a post contains an emoji, it is displayed properly on a themed page. But if I save the HTML output to a file, the emoji comes out something like

eth;#159;#153;#129; 

These are UniCode character (I think), and I need the generated HTML page to show the emoji as a graphic image.

My code that creates the HTML output uses a standard WP_Query object, then outputs the_content within the have_posts loop:

$thestring .= apply_filters('the_content',$post-post_content) // keep adding the content to $thestring

The $thestring variable, which contains all posts content, is then added to an HTML document, and that is output to a HTML file.

When I load the HTML file into the browser, the emoji is shown as something like 🙠. If I load the HTML file into Word 2010 (so I can convert the blog content into a Word document), it also shows up as 🙠.

How do I get the emoji content in the HTML file into a graphic? Is there some library I need to load via the plugin, or some conversion function? Again, the ultimate goal is to get all blog content into a Word document.

Update

I believe the problem is that my plugin is not loading some functions/JS that is used when a template is applied to the page. The template uses the the_content() function in the loop to output the posts. The template will output the emoji images properly.

But if I take the same loop that the template uses and use it in my plugin, the emoji images are not displayed. Any apply_filter to the_content does not matter; the plugin code will not display the emoji graphics. Only the template (applied to a page) will show emoji graphics.

So, the question might be restated as: what functions/includes are used in the page template that I need to add to my plugin?

Topic emoji Wordpress

Category Web


To have your emoji characters displayed correctly, your html document MUST HAVE this meta in the header:

<meta charset="UTF-8">

To insert emoji character into your content, you can ether copy/paste it, or use its numerical code. This will be a code for a hamburger: &#x1F354; resulting this: .

Update

It looks like your wp_posts table's collation belongs to 'utf8_' group. To correctly store emoji characters, your wp_posts table's collation must be one of 'utf8mb4_' group. If it's not, change it with phpMyAdmin, edit, and update your posts.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.