php编码转换函数_PHP教程

WBOY
Freigeben: 2016-07-13 17:39:54
Original
822 Leute haben es durchsucht

        一般情况下用 iconv,只有当遇到无法确定原编码是何种编码,或者iconv转化后无法正常显示时才用mb_convert_encoding 函数。

iconv函数语法 :
<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>

mb_convert_encoding函数语法 :
<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>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486245.htmlTechArticle一般情况下用 iconv,只有当遇到无法确定原编码是何种编码,或者iconv转化后无法正常显示时才用mb_convert_encoding 函数。 iconv函数语法 :...
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!