<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >unicode_encode</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="Unicode Functions" HREF="ref.unicode.html"><LINK REL="PREVIOUS" TITLE="Unicode Functions" HREF="ref.unicode.html"><LINK REL="NEXT" TITLE="unicode_semantics" HREF="function.unicode-semantics.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="ref.unicode.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.unicode-semantics.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.unicode-encode" ></A >unicode_encode</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN235527" ></A ><P > (PHP 5 CVS only)</P >unicode_encode -- Set encoding of a unicode string</DIV ><DIV CLASS="refsect1" ><A NAME="AEN235530" ></A ><H2 >说明</H2 >string <B CLASS="methodname" >unicode_encode</B > ( unicode input, string encoding, int flags )<BR ></BR ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >警告</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P >本函数暂无文档,仅有参数列表。</P ></TD ></TR ></TABLE ></DIV ><P > Takes a unicode string and converts it to a string in the specified <CODE CLASS="parameter" >encoding</CODE >. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN235549" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >input</CODE ></DT ><DD ><P > The unicode string that will be encoded. </P ></DD ><DT ><CODE CLASS="parameter" >encoding</CODE ></DT ><DD ><P > The new encoding for <CODE CLASS="parameter" >input</CODE >. </P ></DD ><DT ><CODE CLASS="parameter" >flags</CODE ></DT ><DD ><P > Flags </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN235570" ></A ><H2 >返回值</H2 ><P > A <A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A > on success, or <TT CLASS="constant" ><B >FALSE</B ></TT > on failure. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN235575" ></A ><H2 >错误/异常</H2 ><P > Emits a <TT CLASS="constant" ><B >E_WARNING</B ></TT > level error if a converter cannot be created for the desired <CODE CLASS="parameter" >encoding</CODE >. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN235580" ></A ><H2 >范例</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN235583" ></A ><P ><B >例 1. A <B CLASS="function" >unicode_encode()</B > example</B ></P ><P > Note: The characters will be seen instead of entities in the output. </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />header </font><font color="#007700">(</font><font color="#DD0000">'Content-Type: text/plain; charset=ISO-8859-2'</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$encoded </font><font color="#007700">= </font><font color="#0000BB">unicode_encode </font><font color="#007700">(</font><font color="#DD0000">'\u0150\u0179'</font><font color="#007700">, </font><font color="#DD0000">'ISO-8859-2'</font><font color="#007700">);<br /><br />echo </font><font color="#DD0000">'Unicode semantics: '</font><font color="#007700">, </font><font color="#0000BB">ini_get </font><font color="#007700">(</font><font color="#DD0000">'unicode_semantics'</font><font color="#007700">), </font><font color="#0000BB">PHP_EOL</font><font color="#007700">;<br />echo </font><font color="#DD0000">'The string itself:'</font><font color="#007700">, </font><font color="#0000BB">$encoded</font><font color="#007700">, </font><font color="#0000BB">PHP_EOL</font><font color="#007700">;<br />echo </font><font color="#DD0000">'The length of the string: '</font><font color="#007700">, </font><font color="#0000BB">strlen </font><font color="#007700">(</font><font color="#0000BB">$encoded</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P >上例的输出类似于:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >Unicode semantics: 1 The string itself: &#336;&#377; The length of the string: 2</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN235590" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><B CLASS="function" >unicode_symantics()</B ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="ref.unicode.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.unicode-semantics.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Unicode Functions</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.unicode.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >unicode_semantics</TD ></TR ></TABLE ></DIV ></BODY ></HTML >