How to solve chinese became question mark after database migration?

A few days ago, I moved one website from production environment to local for modification. The local environment was build with wampserver three years ago, mysql version is out dated.
I got “Unknown collation: utf8mb4_unicode_ci” error so I exported mysql with

mysqldump --compatible=mysql4

After finished modifying, I moved the website back online. During testing I found chinese would become question mark after clicking publish button.
It looks like a database issue and it is. All tables collation was set to latin1_swedish_ci.
Alter table in adminer GUI is inefficient because columns charset need to be set to utf8mb4 too.
Using command is quicker:

alter table convert to character set utf8mb4 collate utf8mb4_unicode_ci;

But it still need to alter table one by one.
The quickest way I found is to search and replace exported sql file with:

Replace DEFAULT CHARSET=latin1; with DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

then import it again.

Fix “Screen Options” not show up on menu admin page of wordpress chinese version since V4.2

A few days ago I updated an old wordpress site of my client, after that, when I was going to add a custom post category to top menu, I found the “Screen Options” would not showing up. So I made a comparation with other wordpress installs, version 4.1.3 is working, english is working, japanese is working, but chinese version not.
The problem is on page “wp-admin/nav-menus.php”, first I thought it maybe some js conflict of chinese version, so I added
define('CONCATENATE_SCRIPTS', false); to wp-config.php to load js seperately, it turns out the js files are exactly the same with other languages, but html structures are not.
I turned to dig the .po files, then found one mistake on line 949 of admin-zh_CN.po

#: wp-admin/users.php:395
msgid "%s user deleted."
msgid_plural "%s users deleted."
msgstr[0] "已删除%d个用户。"

Now I could confirm translation file do has errors, but there are 2000+ items, I only want to find out the screen option part, luckily firefox marked wrong html tags with red color, it’s easy to find out the wrong “strong” tag on line 1085 of admin-zh_CN.po

#: wp-admin/nav-menus.php:520
msgid ""
"To add a custom link, <strong>expand the Custom Links section, enter a URL "
"and link text, and click Add to Menu</strong>"
msgstr ""
"要添加自定义链接,<strong>展开自定义链接小节,输入URL和链接文本,然后点击添加"
"到菜单<strong>"

After correction, I use poedit to regenerate admin-zh_CN.mo then overwrite it with ftp.
Tada! the “Screen Options” works as normal.
Here is the fixed admin-zh_CN.po and admin-zh_CN.mo
languages
Translation is tedious and everyone may make a typo, that’s quite understandable.

Google Web Fonts is unblocked in china mainland

Google resolves fonts.googleapis.com to 203.208.4*.*, which are its IPs in Beijing, so Google Web Fonts could be visited directly in china mainland now (2015-02-28)
google-fonts-unblockedGoogle Web Fonts is blocked again.
replace //fonts.googleapis.com
with //fonts.geekzu.org
(updated on 2016-12-28)

Which ISP should you choose in china?

Location

Location is important if you want good international network speed in china, Beijing, Shanghai and Guangzhou so called 北上广 are the most developed cities in china, they have the best IT Infrastructure.

ISP

There are a lot of ISP in china, but the biggest three are China telecom, China unicom and China mobile(tietong).

Situation of Gehua歌华, Great Wall Broadband长城宽带, broadbandcommunication宽带通 , Founder broadband方正宽带 could not be summarized, simple rule is the more expensive the better.

Compare share of bandwidth and quality:

China telecom is better than China unicom in south china, China unicom is better than China telecom in north china.

On the whole, China telecom > China unicom > China mobile

If you want good international network speed (2015-02-23):

Live in Shanghai and using China telecom, pay 50 yuan 200 yuan (updated on 2015-04-01) more per month to use international boutique network国际精品网 is your best choice. There are too much international traffic, Shanghai telecom have network congestion, don’t use it. (update on 2015-08-13)

International boutique network 国际精品网 is back.: (update on 2021-02-10)

https://sh.189.cn/clhw/

Live in other cities,
China mobile is cheap and it has the most idle bandwidth to international network and it has equal upload and download speed in most places ,
(Fellas, I heared your voice on zhihu, updated on 2016-12-28)
China mobile’s fixed-line broadband user number is growing rapidly in recent years (75.51 million),  more than china unicom (75.472 million) via people
Now china mobile is not the clear winner.
but and it also has many problems:

  • a lot of TCP hijacking, DNS hijacking (Especially China tietong exit)
  • Expired files because of cache
  • no public IPv4 address
  • a lot of sites and IP been blocked temporary or permanent

Use China mobile with a proxy in Hong Kong or neighboring countries (Singapore, Japan etc) is your best choice still a good choice. (updated on 2016-12-28)
Use Shadowsocks over KCPTun to get rid of QoS restrictions is suggested. (updated on 2016-12-28)

Where to download or upgrade chrome in china mainland?

You could download chrome and use the online installer directly (updated on 2020-12-02)

Usually, you could upgrade chrome directly, but not in china mainland, it’s blocked.
If you have friends outside china mainland, you could ask them to download a standalone edition then send it to you.
https://www.google.com/chrome/browser/desktop/index.html?standalone=1
Or download it from mirrors:
http://getchrome.sinaapp.com/
http://buildbot.ikk.me/#download
https://gmirror.org/ (updated on 2016-12-28)
Or use Opera instead.
Download from baoku.360.cn is not recommended, because you need to install 360 Security Guards to download it, after install 360 Security Guards, you would be asked to install 360 Anti-virus, 360 Mobile Assistant, 360 secure browser…

How to fix gravatar not shown in china mainland?

Add this snippet to functions.php:

function dmeng_get_https_avatar($avatar) {
//replace domain
$avatar = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "secure.gravatar.com", $avatar);
//replace protocol
$avatar = str_replace("http://", "https://", $avatar);
return $avatar;
}
add_filter('get_avatar', 'dmeng_get_https_avatar');

Contributed by dmeng

If visitors of your website is mainly from china mainland, there is a better way, duoshuo (a service similar to disqus) provides a mirror of gravatar, add this snippet to functions.php

//Replace Gravatar with duoshuo mirror
function mytheme_get_avatar($avatar) {
    $avatar = str_replace(array("www.gravatar.com","0.gravatar.com","1.gravatar.com","2.gravatar.com"),"gravatar.duoshuo.com",$avatar);
    return $avatar;
}
add_filter( 'get_avatar', 'mytheme_get_avatar', 10, 3 );

Could not know who contributed this method fist, thanks duoshuo!