0

WordPress or PHP are cutting off the text after saving a post. This happens when there is a special character like ’ or ™. For example if I enter the following text:

This isn’t working

and then I save the post, the post will be:

This isn

I assume is not MySQL because I entered the same text and it worked. The wp-config.php contains the following:

define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

And I have tested it with

define('DB_CHARSET', 'utf8');
define('DB_COLLATE', 'latin1_swedish_ci');

The mysql database has latin1_swedish_ci collation and the tables has utf8_general_ci collation.

I've also tried to change the tables collation but it didn't work. I'm using the latest WordPress version. I don't have experience with collations or encoding. So, my question is: Is there a method to make WordPress save the entirely post without cutting off the content when appears a special character?

Hannes Ovrén
  • 21,229
  • 9
  • 65
  • 75
mgreca
  • 86
  • 8

1 Answers1

0

The truncation like that very probably came from latin1 bytes being fed to a utf8 field.

If your client (PHP or whatever) is generating latin1 characters, then you must tell the server that:

⚈  mysql: mysql_set_charset('utf8');  (deprecated)
⚈  mysqli: $mysqli_obj->set_charset('utf8');
⚈  PDO: $db = new PDO('dblib:host=host;dbname=db;charset=UTF-8', $user, $pwd);
Rick James
  • 135,179
  • 13
  • 127
  • 222