Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

mysql - Setting HTML Content-Type charset to UTF-8 "destroys" SQL-requests

On my website I use content that comes either of MySQL-databases or is directly written in the files. The database has the collation utf8_general_ci, the tables (of WordPress) use utf8mb4_unicode_520_ci.

If I don't set header("Content-Type: text/html; charset=UTF-8");, the content that comes from the database is displayed correctly concerning umlauts (?, ?, ü, etc.). But of the content that is directly written in the PHP-files the umlauts are displayed as cryptic signs.

Now if I set header("Content-Type: text/html; charset=UTF-8");, it is the other way around.

How can I manage both ways of content to be displayed correct?

question from:https://stackoverflow.com/questions/65837701/setting-html-content-type-charset-to-utf-8-destroys-sql-requests

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If the content directly written in PHP files does not show up correctly, it means that you used an editor for your PHP source that doesn't save files in UTF-8. Is it a very old editor?

Look for the UTF-8 setting in your editor, open your PHP source files and save them again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...