whyisjake / Simple-Instant-Articles-for-Facebook

Add support for Facebook Instant Articles to your WordPress site.
https://wordpress.org/plugins/simple-facebook-instant-articles/
55 stars 19 forks source link

Encoding problems #60

Closed greatestview closed 8 years ago

greatestview commented 8 years ago

Hi,

we´re using your plugin for a while on a website. Thanks so far, really great! Since the last update from version 0.5.0 to 0.5.3 we encounter some encoding problems in the post content.

Instead of Superkräfte the output in the ia-feed is Superkräfte. I traced the problem back to the function reformat_post_content. There seem to be some general encoding problems with the DOMDocument.

My hotfix is replacing:

        $dom->loadHTML( sprintf(
            '<html><head><meta http-equiv="Content-Type" content="%s" charset="%s"/></head><body>%s</body></html>',
            get_bloginfo( 'html_type' ),
            get_bloginfo( 'charset' ),
            $post_content
        ) );

with:

        $dom->loadHTML( mb_convert_encoding( sprintf(
            '<html><head><meta http-equiv="Content-Type" content="%s" charset="%s"/></head><body>%s</body></html>',
            get_bloginfo( 'html_type' ),
            get_bloginfo( 'charset' ),
            $post_content
        ), 'HTML-ENTITIES', 'UTF-8' ) );

As suggested here.

Could you have a look at that? Thank you.