Source of: /manual/en/function.iconv.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.iconv.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.iconv.php',
1 => 'iconv',
),
'up' =>
array (
0 => 'ref.iconv.php',
1 => 'iconv Functions',
),
'prev' =>
array (
0 => 'function.iconv-substr.php',
1 => 'iconv_substr',
),
'next' =>
array (
0 => 'function.ob-iconv-handler.php',
1 => 'ob_iconv_handler',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.iconv" class="refentry">
<div class="refnamediv">
<h1 class="refname">iconv</h1>
<p class="verinfo">(PHP 4 >= 4.0.5, PHP 5)</p><p class="refpurpose"><span class="refname">iconv</span> — <span class="dc-title">Convert string to requested character encoding</span></p>
</div>
<a name="function.iconv.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">string</span> <span class="methodname"><b>iconv</b></span>
( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$in_charset</tt></span>
, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$out_charset</tt></span>
, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$str</tt></span>
)</div>
<p class="para rdfs-comment">
Performs a character set conversion on the string
<i><tt class="parameter">str</tt></i>
from <i><tt class="parameter">in_charset</tt></i>
to <i><tt class="parameter">out_charset</tt></i>
.
</p>
</div>
<a name="function.iconv.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">in_charset</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The input charset.
</p>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">out_charset</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The output charset.
</p>
<p class="para">
If you append the string <i>//TRANSLIT</i> to
<i><tt class="parameter">out_charset</tt></i>
transliteration is activated. This
means that when a character can't be represented in the target charset,
it can be approximated through one or several similarly looking
characters. If you append the string <i>//IGNORE</i>,
characters that cannot be represented in the target charset are silently
discarded. Otherwise, <i><tt class="parameter">str</tt></i>
is cut from the first
illegal character and an <b><tt class="constant">E_NOTICE</tt></b> is generated.
</p>
</dd>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">str</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The string to be converted.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.iconv.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns the converted string or <b><tt class="constant">FALSE</tt></b> on failure.
</p>
</div>
<a name="function.iconv.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
</p><div class="example">
<p><b>Example #1 <b>iconv()</b> example</b></p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br />$text </span><span style="color: #007700">= </span><span style="color: #DD0000">"This is the Euro symbol '€'."</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #DD0000">'Original : '</span><span style="color: #007700">, </span><span style="color: #0000BB">$text</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'TRANSLIT : '</span><span style="color: #007700">, </span><span style="color: #0000BB">iconv</span><span style="color: #007700">(</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">, </span><span style="color: #DD0000">"ISO-8859-1//TRANSLIT"</span><span style="color: #007700">, </span><span style="color: #0000BB">$text</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'IGNORE : '</span><span style="color: #007700">, </span><span style="color: #0000BB">iconv</span><span style="color: #007700">(</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">, </span><span style="color: #DD0000">"ISO-8859-1//IGNORE"</span><span style="color: #007700">, </span><span style="color: #0000BB">$text</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'Plain : '</span><span style="color: #007700">, </span><span style="color: #0000BB">iconv</span><span style="color: #007700">(</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">, </span><span style="color: #DD0000">"ISO-8859-1"</span><span style="color: #007700">, </span><span style="color: #0000BB">$text</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
<div class="example-contents para"><p>The above example will output
something similar to:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
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
This is the Euro symbol '
</pre></div>
</div>
</div><p>
</p>
</div>
</div><?php manual_footer(); ?>