PHP garbled problem 1. How does PHP process uploaded CSV files?
You can use the fgetcsv function: -- Read a line from the file pointer and parse the CSV field, but it cannot process the Chinese inside; so after uploading, you must first convert the CSV to encoding;
PHP garbled problem 2. Encoding conversion;
<ol class="dp-xml"><li class="alt"><span><span>iconv("GB2312","UTF-8<br>//IGNORE",file_get_contents($uploadfile)); </span></span></li></ol>
ignore means ignoring errors during conversion; but it seems better to use another function mb_convert_encoding;
PHP garbled problem 3. Garbled characters when sending Jmail may also be due to this reason:
If the web page is UTF8 encoded; you can $jmail->charset = 'utf8';
But most of the inboxes are GB2312, you can convert the original files with mb_convert_encoding;
<ol class="dp-xml"> <li class="alt"><span><span>$</span><span class="attribute">zhengwen</span><span> = </span><span class="attribute-value">'世上只有妈妈好'</span><span>; </span></span></li> <li> <span>$jmail-</span><span class="tag">></span><span class="attribute">Body</span><span> = </span><span class="attribute-value">mb_convert_<br>encoding</span><span>($zhennwen, 'GB2312', 'UTF-8'); </span> </li> </ol>
I hope to solve the three PHP garbled problems introduced in this article Skills and experience can help everyone solve problems.