0

I'm experiencing serious problems with accents (é, í, ú...) & special chars (like "ñ" or "¿") replaced by strange characters in content and menus.

  • The site is in spanish. I use Wordpress. Never migrated.
  • The problem appears using PHP 7.1, 7.2 and 7.3. If I back to PHP 7.0 everything is perfect.
  • I did many tests in staging environment with no plugins and default WP theme, but no results.

FYI these are my data:

Wp-config:
define('DB_CHARSET', 'utf8mb4');

define('DB_COLLATE', '');

All the tables in PHPMyAdmin are utf8mb4_unicode_ci except Yoast tables that are in utf8_general_ci…

  • character_set_client: utf8mb4
  • character_set_connection: utf8mb4
  • character_set_database: utf8
  • character_set_filesystem: binary
  • character_set_results: utf8mb4
  • character_set_server: utf8
  • character_set_system: utf8

  • collation_connection: utf8mb4_unicode_ci

  • collation_database: utf8_general_ci
  • collation_server: utf8_general_ci

Is it a problem with 'DB-CHARSET'? (content stored in wp_posts or wp_comments shows many wrong accents) or PHP? (mbstring, maybe?) or Apache? (htaccess looks good, adding AddDefaultCharset utf-8 doesn't solve anything).

What can I do or test and how? (I'm not a developer but I can manage some basics).

Thanks in advance for your help!

Bobby
  • 23
  • 4
  • See https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored -- if `é, í, ú` looks like `é, í, ú`, then you have "Mojibake". – Rick James May 13 '20 at 14:32
  • Yes, it's exactly what is happening. I'm not a developer, how can I solve it easily, taking into account my current db data (all in utf8 or utf8mb4, I assume it should be ok)? – Bobby May 14 '20 at 10:54
  • The link provides a few one-line solutions; the problem is to figure out which one is relevant to your code. Somewhere you have "latin1", but it might not be obvious. – Rick James May 14 '20 at 16:47
  • That's the point, it's weird because apparently (after the query I posted above) everything is in uft8 or utf8mb4... so it's quite difficult understand where effectively is the issue :( – Bobby May 16 '20 at 08:45
  • "Everthing"? The column definition, the connection parameters, the encoding in the client, etc?. And don't use any conversion functions. – Rick James May 16 '20 at 17:12
  • Well, I meant the data I posted at the beginning: all character sets in utf8 or utf8mb4. I checked the structure of many tables and their collation is always utf8mb4_unicode_ci. I also checked the source of a live page and it is ... I also tried to add AddDefaultCharset utf-8 to my htcaccess file but still no results. As I mentioned, I'm not a developer but with simple instructions I may go ahead. But with this landscape I can't see where is the issue. Do you have any idea about whatelse can I easily check or do, Rick? :) – Bobby May 19 '20 at 14:54
  • This landscape is littered with the corpses of thousands of programmers and DBAs. Somewhere in the WP setup is the specification of the encoding of the data in the client. The client is getting data (keystrokes / copy+paste / etc) from somewhere. If those two don't agree, a mess ensues. (Sorry "simple instructions" are elusive.) – Rick James May 19 '20 at 20:09
  • Drupal, WordPress, and any other product that uses PHP: Turn off mbstring.encoding_translation. Probably everything to do with mbstring should be avoided. amending your settings.php database connection by adding: $databases['default']['default'] = array( 'driver' => 'mysql', 'database' => 'databasename', 'username' => 'username', 'password' => 'password', 'host' => 'localhost', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', ); – Rick James May 19 '20 at 20:09
  • Got it and yes, it gives a lot of headache. I understand that isn't easy to catch where the problem is. I've just tried your last recommendations (in staging) but nothing happens. I'm lost. :( – Bobby May 20 '20 at 09:46
  • Hey Rick, I was reading your post: https://stackoverflow.com/questions/38363566/trouble-with-utf-8-characters-what-i-see-is-not-what-i-stored?noredirect=1&lq=1 .... I got mobibake for "old" content. But if I create and publish (immediately) a new content, it is shown properly, but if I open again the editor, I get question marks instead of accents. So it's very strange, looks like a mix of issues, but maybe it can be useful to understand more the issue. Any new idea? – Bobby May 21 '20 at 09:51
  • Ouch! If you have some 'correct' content intermixed (in the same column in the same table) with Mojibaked content, you have a big mess. – Rick James May 21 '20 at 20:46
  • That link has a debugging suggestion for SELECT HEX...; see if you can get the HEX for some text that is in trouble. – Rick James May 21 '20 at 20:47

0 Answers0