uTools-Manuals/docs/php/iconv_mime_encode.html
2019-04-28 19:00:34 +08:00

221 lines
11 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Composes a MIME header field</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.iconv-mime-encode" class="refentry">
<div class="refnamediv">
<h1 class="refname">iconv_mime_encode</h1>
<p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">iconv_mime_encode</span> &mdash; <span class="dc-title">Composes a <em>MIME</em> header field</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.iconv-mime-encode-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>iconv_mime_encode</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$field_name</code></span>
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$field_value</code></span>
[, <span class="methodparam"><span class="type">array</span> <code class="parameter">$preferences</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
] ) : <span class="type">string</span></div>
<p class="para rdfs-comment">
Composes and returns a string that represents a valid <em>MIME</em>
header field, which looks like the following:
<div class="example-contents screen">
<div class="cdata"><pre>
Subject: =?ISO-8859-1?Q?Pr=FCfung_f=FCr?= Entwerfen von einer MIME kopfzeile
</pre></div>
</div>
In the above example, &quot;Subject&quot; is the field name and the portion that
begins with &quot;=?ISO-8859-1?...&quot; is the field value.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.iconv-mime-encode-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">field_name</code></dt>
<dd>
<p class="para">
The field name.
</p>
</dd>
<dt>
<code class="parameter">field_value</code></dt>
<dd>
<p class="para">
The field value.
</p>
</dd>
<dt>
<code class="parameter">preferences</code></dt>
<dd>
<p class="para">
You can control the behaviour of <span class="function"><strong>iconv_mime_encode()</strong></span>
by specifying an associative array that contains configuration items
to the optional third parameter <code class="parameter">preferences</code>.
The items supported by <span class="function"><strong>iconv_mime_encode()</strong></span> are
listed below. Note that item names are treated case-sensitive.
<table class="doctable table">
<caption><strong>Configuration items supported by <span class="function"><strong>iconv_mime_encode()</strong></span></strong></caption>
<thead>
<tr>
<th>Item</th>
<th>Type</th>
<th>Description</th>
<th>Default value</th>
<th>Example</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td>scheme</td>
<td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
<td>
Specifies the method to encode a field value by. The value of
this item may be either &quot;B&quot; or &quot;Q&quot;, where &quot;B&quot; stands for
<em>base64</em> encoding scheme and &quot;Q&quot; stands for
<em>quoted-printable</em> encoding scheme.
</td>
<td>B</td>
<td>B</td>
</tr>
<tr>
<td>input-charset</td>
<td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
<td>
Specifies the character set in which the first parameter
<code class="parameter">field_name</code> and the second parameter
<code class="parameter">field_value</code> are presented. If not given,
<span class="function"><strong>iconv_mime_encode()</strong></span> assumes those parameters
are presented to it in the
<a href="iconv.configuration.html" class="link">iconv.internal_encoding</a>
ini setting.
</td>
<td>
<a href="iconv.configuration.html" class="link">iconv.internal_encoding</a>
</td>
<td>ISO-8859-1</td>
</tr>
<tr>
<td>output-charset</td>
<td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
<td>
Specifies the character set to use to compose the
<em>MIME</em> header.
</td>
<td>
<a href="iconv.configuration.html" class="link">iconv.internal_encoding</a>
</td>
<td>UTF-8</td>
</tr>
<tr>
<td>line-length</td>
<td><span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span></td>
<td>
Specifies the maximum length of the header lines. The resulting
header is &quot;folded&quot; to a set of multiple lines in case
the resulting header field would be longer than the value of this
parameter, according to
<a href="http://www.faqs.org/rfcs/rfc2822" class="link external">&raquo;&nbsp;RFC2822 - Internet Message Format</a>.
If not given, the length will be limited to 76 characters.
</td>
<td>76</td>
<td>996</td>
</tr>
<tr>
<td>line-break-chars</td>
<td><span class="type"><a href="language.types.string.html" class="type string">string</a></span></td>
<td>
Specifies the sequence of characters to append to each line
as an end-of-line sign when &quot;folding&quot; is performed on a long header
field. If not given, this defaults to &quot;\r\n&quot;
(<em>CR</em> <em>LF</em>). Note that
this parameter is always treated as an ASCII string regardless
of the value of <em>input-charset</em>.
</td>
<td>\r\n</td>
<td>\n</td>
</tr>
</tbody>
</table>
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.iconv-mime-encode-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Returns an encoded <em>MIME</em> field on success,
or <strong><code>FALSE</code></strong> if an error occurs during the encoding.
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.iconv-mime-encode-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-2892">
<p><strong>Example #1 <span class="function"><strong>iconv_mime_encode()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$preferences&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"input-charset"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"ISO-8859-1"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"output-charset"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"line-length"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">76</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"line-break-chars"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"\n"<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$preferences</span><span style="color: #007700">[</span><span style="color: #DD0000">"scheme"</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #DD0000">"Q"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;yields&nbsp;"Subject:&nbsp;=?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?="<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">iconv_mime_encode</span><span style="color: #007700">(</span><span style="color: #DD0000">"Subject"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Prüfung&nbsp;Prüfung"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$preferences</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$preferences</span><span style="color: #007700">[</span><span style="color: #DD0000">"scheme"</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #DD0000">"B"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;yields&nbsp;"Subject:&nbsp;=?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?="<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">iconv_mime_encode</span><span style="color: #007700">(</span><span style="color: #DD0000">"Subject"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Prüfung&nbsp;Prüfung"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$preferences</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.iconv-mime-encode-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="imap_binary.html" class="function" rel="rdfs-seeAlso">imap_binary()</a> - Convert an 8bit string to a base64 string</span></li>
<li class="member"><span class="function"><a href="mb_encode_mimeheader.html" class="function" rel="rdfs-seeAlso">mb_encode_mimeheader()</a> - 为 MIME 头编码字符串</span></li>
<li class="member"><span class="function"><a href="imap_8bit.html" class="function" rel="rdfs-seeAlso">imap_8bit()</a> - Convert an 8bit string to a quoted-printable string</span></li>
<li class="member"><span class="function"><a href="quoted_printable_encode.html" class="function" rel="rdfs-seeAlso">quoted_printable_encode()</a> - 将 8-bit 字符串转换成 quoted-printable 字符串</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>