Generally, iconv is used. Use mb_convert_encoding only when it is impossible to determine what the original encoding is, or when iconv cannot be displayed normally after conversion.
function.
iconv function syntax: <font color="#000000"><font color="#0000bb"><?php<code><font color="#000000"><font color="#0000bb"><?php<br></font><font color="#007700">echo </font><font color="#0000bb">iconv</font><font color="#007700">(</font><font color="#dd0000">"ISO-8859-1"</font><font color="#007700">, </font><font color="#dd0000">"UTF-8"</font><font color="#007700">,
</font><font color="#dd0000">"This is a test."</font><font color="#007700">);<br></font><font color="#0000bb">?></font> </font>
echo iconv("ISO-8859-1", "UTF-8",
"This is a test.");
?>
mb_convert_encoding function syntax: <font color="#000000"><font color="#0000bb"><?php<br></font><font color="#ff8000">/* Convert internal character encoding to SJIS */<br></font><font color="#0000bb">$str </font><font color="#007700">= </font><font color="#0000bb">mb_convert_encoding</font><font color="#007700">(</font><font color="#0000bb">$str</font><font color="#007700">, </font><font color="#dd0000">"SJIS"</font><font color="#007700">);<br><br></font><font color="#ff8000">/* Convert EUC-JP to UTF-7 */<br></font><font color="#0000bb">$str
</font><font color="#007700">= </font><font color="#0000bb">mb_convert_encoding</font><font color="#007700">(</font><font color="#0000bb">$str</font><font color="#007700">, </font><font color="#dd0000">"UTF-7"</font><font color="#007700">, </font><font color="#dd0000">"EUC-JP"</font><font color="#007700">);<br><br></font><font color="#ff8000">/* Auto detect encoding from JIS, eucjp-win, sjis-win, then
convert str to UCS-2LE */<br></font><font color="#0000bb">$str </font><font color="#007700">= </font><font color="#0000bb">mb_convert_encoding</font><font color="#007700">(</font><font color="#0000bb">$str</font><font color="#007700">,
</font><font color="#dd0000">"UCS-2LE"</font><font color="#007700">, </font><font color="#dd0000">"JIS, eucjp-win, sjis-win"</font><font color="#007700">);<br><br></font><font color="#ff8000">/* "auto" is expanded to
"ASCII,JIS,UTF-8,EUC-JP,SJIS" */<br></font><font color="#0000bb">$str </font><font color="#007700">= </font><font color="#0000bb">mb_convert_encoding</font><font color="#007700">(</font><font color="#0000bb">$str</font><font color="#007700">,
</font><font color="#dd0000">"EUC-JP"</font><font color="#007700">, </font><font color="#dd0000">"auto"</font><font color="#007700">);<br></font><font color="#0000bb">?></font> </font>
<font color="#000000"><font color="#0000bb"><?php<br></font><font color="#ff8000">/* Convert internal character encoding to SJIS */</li></font><font color="#0000bb ">$str </font><font color="#007700">= </font><font color="#0000bb">mb_convert_encoding</font><font color="#007700">(</font> <font color="#0000bb">$str</font><font color="#007700">, </font><font color="#dd0000">"SJIS"</font><font color=" #007700">);</p><p align="left"></font><font color="#ff8000">/* Convert EUC-JP to UTF-7 */<div style="display:none;"></font><font color="# 0000bb">$str
</font><font color="#007700">= </font><font color="#0000bb">mb_convert_encoding</font><font color="#007700">(</font><font color= "#0000bb">$str</font><font color="#007700">, </font><font color="#dd0000">"UTF-7"</font><font color="#007700 ">, </font><font color="#dd0000">"EUC-JP"</font><font color="#007700">);<span id="url" itemprop="url"></span></font><font color= "#ff8000">/* Auto detect encoding from JIS, eucjp-win, sjis-win, then
convert str to UCS-2LE */<span id="indexUrl" itemprop="indexUrl"></font><font color="#0000bb">$str </font><font color="#007700">= </font><font color="# 0000bb">mb_convert_encoding</font><font color="#007700">(</font><font color="#0000bb">$str</font><font color="#007700">,
</font><font color="#dd0000">"UCS-2LE"</font><font color="#007700">, </font><font color="#dd0000">"JIS, eucjp- win, sjis-win"</font><font color="#007700">);</span><span id="isOriginal" itemprop="isOriginal"></font><font color="#ff8000">/* "auto" is expanded to
"ASCII,JIS,UTF-8,EUC-JP,SJIS" */</span></font><font color="#0000bb">$str </font><font color="#007700">= < /font><font color="#0000bb">mb_convert_encoding</font><font color="#007700">(</font><font color="#0000bb">$str</font><font color= "#007700">,
</font><font color="#dd0000">"EUC-JP"</font><font color="#007700">, </font><font color="#dd0000">"auto"</font><font color="#dd0000">" font><font color="#007700">);<span id="isBasedOnUrl" itemprop="isBasedOnUrl"></font><font color="#0000bb">?></font> </font>
http://www.bkjia.com/PHPjc/486245.html