The cause of garbled code problem and its solution
This article mainly explains the causes and solutions of the garbled code problem. The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn the causes and solutions of the garbled problem.
PHP garbled problem 1. How does PHP deal with uploaded CSV files?
You can use the fgetcsv function:-- read a line from the file pointer and parse the CSV field, but he can't handle the Chinese inside; so after uploading, you have to transcode the csv first.
PHP garbled problem 2. Transcoding
Iconv ("GB2312", "UTF-8"
/ / IGNORE ", file_get_contents ($uploadfile))
Ignore means to ignore conversion errors; but it seems better to mb_convert_encoding with another function
PHP garbled problem 3. Garbled code when Jmail sends a message may also be this reason:
If the page is UTF8 encoded; you can $jmail- > charset = 'utf8'
But most of the inboxes are GB2312, so you can use mb_convert_encoding to transfer the original files.
$zhengwen = 'only moms are good in the world'
$jmail- > Body = mb_convert_
Encoding ($zhennwen, 'GB2312',' UTF-8')
Thank you for your reading. The above is the content of "the cause and solution of garbled code problem". After the study of this article, I believe you have a deeper understanding of the cause and solution of garbled code problem. The specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!