Reasons and solutions for sudden garbled characters in WordPress

Original link: https://www.physixfan.com/wordpress-turanluanmadeyuanyinhejiejuefangan/

When I woke up, my blog suddenly turned into this garbled painting style:

Obviously I haven’t changed anything! How could it suddenly break down? And my other WordPress blogs with similar settings and want to use the same server have not encountered this problem?

I also remembered that another blog I followed before also became like this:

I consulted the customer service of our blog server, and after waiting for a day, they didn’t figure out why.

The weirdest problem is that it is useless to restore the previous backup, and the restored one is still garbled!

So I asked my two master friends wsmlby and skysniper for advice, and finally got an idea. After I had an idea, I contacted the customer service of the server again, and finally the problem was solved.

It turns out that the garbled characters are caused by the inconsistency between the encoding of the database and the encoding of WordPress. The WordPress website, which was built a long time ago, uses the encoding “latin1_swedish_ci” for its database, but now the default encoding of WordPress is UTF-8. I don’t know which day suddenly the server seems to have changed the settings, so if the encoding is not specified, the old WordPress website will encounter this encoding inconsistency problem. There is no problem with the newer WordPress website because the database of WordPress is also UTF-8 encoded.

If your WordPress also encounters the same garbled problem, the solution is simple: specify the encoding in config.php as follows:

define ('DB_CHARSET', 'latin1');

References:

The post WordPress suddenly garbled causes and solutions appeared first on physixfan .

This article is transferred from: https://www.physixfan.com/wordpress-turanluanmadeyuanyinhejiejuefangan/
This site is only for collection, and the copyright belongs to the original author.