Plugin won’t output characters with diacritics properly


I’m developing a custom plugin for a WordPress based website.
I have a function that will output some html to the site like this:

function display_content()
    $content = '<div><p>Śóme ćóńtęńt with diąćritićś</p></div>';
    return $content;

add_shortcode('my_shortcode', 'display_content');

On the website the output of this shortcode will have all the characters with diacritics replaced by ‘�’. The content that is not generated by the plugin does not have this issue. The characters look fine in the source code too.

It’s some encoding problem, but I can’t find what is the source of it. Is WordPress or the server misconfigured? Am I doing something wrong with this plugin?

I looked online but it’s extremely hard to find anything in the 1000s of results about wrong encoding in the database. I don’t think this applies here since the content from the database looks fine, but I’m pretty new to WP and I might be wrong here.

Pirate 4 months 0 Answers 10 views 0

Leave an answer