php-doc-en/reference/iconv/functions/iconv-mime-encode.xml
2014-09-05 07:44:07 +00:00

220 lines
7.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.iconv-mime-encode" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>iconv_mime_encode</refname>
<refpurpose>Composes a <literal>MIME</literal> header field</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>iconv_mime_encode</methodname>
<methodparam><type>string</type><parameter>field_name</parameter></methodparam>
<methodparam><type>string</type><parameter>field_value</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>preferences</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Composes and returns a string that represents a valid <literal>MIME</literal>
header field, which looks like the following:
<screen>
<![CDATA[
Subject: =?ISO-8859-1?Q?Pr=FCfung_f=FCr?= Entwerfen von einer MIME kopfzeile
]]>
</screen>
In the above example, "Subject" is the field name and the portion that
begins with "=?ISO-8859-1?..." is the field value.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>field_name</parameter></term>
<listitem>
<para>
The field name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>field_value</parameter></term>
<listitem>
<para>
The field value.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>preferences</parameter></term>
<listitem>
<para>
You can control the behaviour of <function>iconv_mime_encode</function>
by specifying an associative array that contains configuration items
to the optional third parameter <parameter>preferences</parameter>.
The items supported by <function>iconv_mime_encode</function> are
listed below. Note that item names are treated case-sensitive.
<table>
<title>Configuration items supported by <function>iconv_mime_encode</function></title>
<tgroup cols="5">
<thead>
<row>
<entry>Item</entry>
<entry>Type</entry>
<entry>Description</entry>
<entry>Default value</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry>scheme</entry>
<entry><type>string</type></entry>
<entry>
Specifies the method to encode a field value by. The value of
this item may be either "B" or "Q", where "B" stands for
<literal>base64</literal> encoding scheme and "Q" stands for
<literal>quoted-printable</literal> encoding scheme.
</entry>
<entry>B</entry>
<entry>B</entry>
</row>
<row>
<entry>input-charset</entry>
<entry><type>string</type></entry>
<entry>
Specifies the character set in which the first parameter
<parameter>field_name</parameter> and the second parameter
<parameter>field_value</parameter> are presented. If not given,
<function>iconv_mime_encode</function> assumes those parameters
are presented to it in the
<link linkend="iconv.configuration">iconv.internal_encoding</link>
ini setting.
</entry>
<entry>
<link linkend="iconv.configuration">iconv.internal_encoding</link>
</entry>
<entry>ISO-8859-1</entry>
</row>
<row>
<entry>output-charset</entry>
<entry><type>string</type></entry>
<entry>
Specifies the character set to use to compose the
<literal>MIME</literal> header.
</entry>
<entry>
<link linkend="iconv.configuration">iconv.internal_encoding</link>
</entry>
<entry>UTF-8</entry>
</row>
<row>
<entry>line-length</entry>
<entry><type>integer</type></entry>
<entry>
Specifies the maximum length of the header lines. The resulting
header is "folded" to a set of multiple lines in case
the resulting header field would be longer than the value of this
parameter, according to
<link xlink:href="&url.rfc;2822">RFC2822 - Internet Message Format</link>.
If not given, the length will be limited to 76 characters.
</entry>
<entry>76</entry>
<entry>996</entry>
</row>
<row>
<entry>line-break-chars</entry>
<entry><type>string</type></entry>
<entry>
Specifies the sequence of characters to append to each line
as an end-of-line sign when "folding" is performed on a long header
field. If not given, this defaults to "\r\n"
(<literal>CR</literal> <literal>LF</literal>). Note that
this parameter is always treated as an ASCII string regardless
of the value of <literal>input-charset</literal>.
</entry>
<entry>\r\n</entry>
<entry>\n</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an encoded <literal>MIME</literal> field on success,
or &false; if an error occurs during the encoding.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>iconv_mime_encode</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$preferences = array(
"input-charset" => "ISO-8859-1",
"output-charset" => "UTF-8",
"line-length" => 76,
"line-break-chars" => "\n"
);
$preferences["scheme"] = "Q";
// This yields "Subject: =?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?="
echo iconv_mime_encode("Subject", "Prüfung Prüfung", $preferences);
$preferences["scheme"] = "B";
// This yields "Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?="
echo iconv_mime_encode("Subject", "Prüfung Prüfung", $preferences);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>imap_binary</function></member>
<member><function>mb_encode_mimeheader</function></member>
<member><function>imap_8bit</function></member>
<member><function>quoted_printable_encode</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->