Character printing conflicts when using different

2019-08-31 08:26发布

Would someone please tell me how to solve this encoding conflict?

Note: My files are saved as UTF-8 files.

When I use:

<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

Webpage shows chars below as normal (they are hard-coded in the page):

çÇ, ğĞ, şŞ

But when the same characters come from DB (encoded with mysqli) they appear abnormal:

��, ��, ��

When I use:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<meta http-equiv="Content-language" content="tr">

Webpage shows chars below abnormal (they are hard-coded in the page):

ğâ, ıİ, şı

But when the same characters come from DB (encoded with mysqli) they appear normal:

çÇ, ğĞ, şŞ

1条回答
beautiful°
2楼-- · 2019-08-31 09:05

After reading the post as given by @Mihai above, I solved the problem with $mysqli->set_charset('utf8mb4'); and just kept <meta charset="utf-8">. That's it!

查看更多
登录 后发表回答