Strange characters appearing in wordpress

2019-07-21 11:10发布

I'm having a niggling wordpress problem

Whenever i'm adding an Apostrophe to a wordpress post I create

'

Its saving as a strange set of characters

’

I've used wordpress many times, never encountered this problem

I've uninstalled every single plugin, and the problem remains

I read somewhere to comment out these lines in wp-config.php but it doesn't help for new posts

/** Database Charset to use in creating database tables. */
//define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
//define('DB_COLLATE', '');

Can someone help me? DO need to set the Charset to override somewhere? How??

3条回答
The star\"
2楼-- · 2019-07-21 11:25

I have to update the thread, as follows. I followed just about every tutorial out there addressing utf-8 mismatch, nothing helped Finally we spotted some phishing code had been injected into the root index file (also linked to some 3rd party adult site, but our site was not redirecting , Needless to say, we cleaned that up Many thanks for everyone for helping, especially @user850010 I hope This thread will be useful for others

查看更多
来,给爷笑一个
3楼-- · 2019-07-21 11:35

If that strange character is stored in DB, then it seems that your DB is not set up with the UTF8 charset, so you can uncomment those 2 lines in wp-config.php, since they are not the source of the problem.

You have a comprehensive tutorial how to convert Character Sets with WordPress Database but here is the short list what to do:

  • Make a backup of your DB
  • Maybe it would be better make a copy of your site on your local computer and try the below changes there

  • Convert DB (this will not affect existing tables, just those future new created tables)

    ALTER DATABASE MyDb CHARACTER SET utf8;

  • convert any tables in the database that are not already in the desired format.

    Focus on the tables wp_posts and wp_postmeta

    ALTER TABLE wp_posts CHARACTER SET utf8

    ALTER TABLE wp_postmeta CHARACTER SET utf8

  • individually alter each column of each table to use the correct the character set. This is not a simple process, read carefully the section of above link regarding columns.

查看更多
走好不送
4楼-- · 2019-07-21 11:43

Run this query:

ALTER DATABASE MyDb CHARACTER SET utf8;

After edit wp_config.php and set:

define('DB_CHARSET', 'utf8');
查看更多
登录 后发表回答