Atma
Atma

Reputation: 29767

php characters in pdf turn to question marks when set to utf-8

I'm using the "wordpress pdf templates" plugin. In my php pdf generating code, I set the type to utf-8 with this:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

When I do this, it turns the word workers' to:

workers?

If I remove the utf-8 designation it looks like this:

workers’

My code is very simple and looks like this:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div class="post-content">
            <?php the_content(); ?>
        </div>
</body>
</html>

What am I doing wrong?

Upvotes: 1

Views: 1036

Answers (1)

YasharF
YasharF

Reputation: 642

This could be because of an encoding mismatch.

One of the places to check is your wp-config.ph since that is one place that the encoding is also defined. Ref: https://www.tipsandtricks-hq.com/how-to-fix-the-character-encoding-problem-in-wordpress-1480

Also note that you have a potential for problems to occur anywhere that one part of your system talks to another. Some of these components are:

  • Your editor that you’re creating the PHP/HTML files in
  • The web browser people are viewing your site through
  • Your PHP web application running on the web server
  • The MySQL database
  • Anywhere else external you’re reading/writing data from (memcached, APIs, RSS feeds, etc)

Ref: https://webmonkeyuk.wordpress.com/2011/04/23/how-to-avoid-character-encoding-problems-in-php

Upvotes: 1

Related Questions