<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.iconv" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>iconv</refname>
  <refpurpose>Convert a string from one character encoding to another</refpurpose>
 </refnamediv>
 
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type class="union"><type>string</type><type>false</type></type><methodname>iconv</methodname>
   <methodparam><type>string</type><parameter>from_encoding</parameter></methodparam>
   <methodparam><type>string</type><parameter>to_encoding</parameter></methodparam>
   <methodparam><type>string</type><parameter>string</parameter></methodparam>
  </methodsynopsis>
  <para>
   Converts <parameter>string</parameter> from <parameter>from_encoding</parameter>
   to <parameter>to_encoding</parameter>.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>from_encoding</parameter></term>
     <listitem>
      <para>
       The current encoding used to interpret <parameter>string</parameter>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>to_encoding</parameter></term>
     <listitem>
      <para>
       The desired encoding of the result.
      </para>
      <para>
       If the string <literal>//TRANSLIT</literal> is appended to
       <parameter>to_encoding</parameter>, then transliteration is activated. This
       means that when a character can't be represented in the target charset,
       it may be approximated through one or several similarly looking
       characters. If the string <literal>//IGNORE</literal> is appended,
       characters that cannot be represented in the target charset are silently
       discarded. Otherwise, <constant>E_NOTICE</constant> is generated and the function
       will return &false;.
      </para>
      <caution>
       <para>
        If and how <literal>//TRANSLIT</literal> works exactly depends on the
        system's iconv() implementation (cf. <constant>ICONV_IMPL</constant>).
        Some implementations are known to ignore <literal>//TRANSLIT</literal>,
        so the conversion is likely to fail for characters which are illegal for
        the <parameter>to_encoding</parameter>.
       </para>
      </caution>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>string</parameter></term>
     <listitem>
      <para>
       The &string; to be converted.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns the converted string,&return.falseforfailure;.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>iconv</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$text = "This is the Euro symbol '€'.";

echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE   : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain    : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;

?>
]]>
    </programlisting>
    &example.outputs.similar;
    <screen>
<![CDATA[
Original : This is the Euro symbol '€'.
TRANSLIT : This is the Euro symbol 'EUR'.
IGNORE   : This is the Euro symbol ''.
Plain    :
Notice: iconv(): Detected an illegal character in input string in .\iconv-example.php on line 7
]]>
    </screen>
   </example>
  </para>
 </refsect1>

 <refsect1 role="notes">
  &reftitle.notes;
  <note>
   <para>
    The character encodings and options available depend on the installed implementation
    of iconv. If the argument to <parameter>from_encoding</parameter>
    or <parameter>to_encoding</parameter> is not supported on the current system, &false;
    will be returned.
   </para>
  </note>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>mb_convert_encoding</function></member>
    <member><methodname>UConverter::transcode</methodname></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
-->
