A problem occurs when mysql extracts Chinese characters and creates an email client. the content of an email is html, the header is UTF-8, and the header is gb2312. In navicat, we can see that the Chinese in the content is correct, but there is a problem after reading it in the php program. then we can read it by adding set names GBK before reading the database. I can't figure it out more and more. before writing data to the database in the program, there is a set names encoding according to the Mail header. The Mail content should be utf8. Why did I read it and ask for help from GBK? I don't understand.
Reply to discussion (solution)
No set names utf8 is executed before the database is inserted, and the PHP file is also saved as UTF-8 encoding.
No set names utf8 is executed before the database is inserted, and the PHP file is also saved as UTF-8 encoding. If the correct encoding is not set before the database is inserted, will it be garbled in navicat? I rely on the code of the mail to execute the set names project before the insert. the code is utf8.
I still don't understand why the charset in the header file is different from the charset in html.
Subject: =? UTF-8? B? M + aciOenr + WIhuaciOe7k + wnscsi =? =
Content-Type: text/html;
Charset = "UTF-8"
Content-Transfer-Encoding: quoted-printable
Date: Tue, 26 Mar 2013 05:09:07 + 0100
W3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
>
If the correct encoding is not set before the database is inserted, will it be garbled in navicat?
Not necessarily, you insert gbk data, and your navicat may be gbk encoding by default. So it is normal.
It depends on what you set names.
Character set declaration is just a label.
Character set declaration is just a label.
Worship God ~
What is your page code?
Change all to UTF-8
If garbled code occurs, it is the encoding problem. let's see what went wrong.
Change to gb2312