Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 3999

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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>Convert string to requested character encoding</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.iconv-substr.html">iconv_substr</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ob-iconv-handler.html">ob_iconv_handler</a></div>
 <div class="up"><a href="ref.iconv.html">iconv Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.iconv" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">iconv</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.5, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">iconv</span> &mdash; <span class="dc-title">Convert string to requested character encoding</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.iconv-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>iconv</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$in_charset</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$out_charset</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   )</div>

  <p class="para rdfs-comment">
   Performs a character set conversion on the string
   <code class="parameter">str</code> from <code class="parameter">in_charset</code>
   to <code class="parameter">out_charset</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.iconv-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">in_charset</code></dt>

     <dd>

      <p class="para">
       The input charset.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">out_charset</code></dt>

     <dd>

      <p class="para">
       The output charset.
      </p>
      <p class="para">
       If you append the string <em>//TRANSLIT</em> to
       <code class="parameter">out_charset</code> transliteration is activated. This
       means that when a character can&#039;t be represented in the target charset,
       it can be approximated through one or several similarly looking
       characters. If you append the string <em>//IGNORE</em>,
       characters that cannot be represented in the target charset are silently
       discarded. Otherwise, <strong><code>E_NOTICE</code></strong> is generated and the function
       will return <strong><code>FALSE</code></strong>.
      </p>
      <div class="caution"><strong class="caution">Caution</strong>
       <p class="para">
        If and how <em>//TRANSLIT</em> works exactly depends on the
        system&#039;s iconv() implementation (cf. <strong><code>ICONV_IMPL</code></strong>).
        Some implementations are known to ignore <em>//TRANSLIT</em>,
        so the conversion is likely to fail for characters which are illegal for
        the <code class="parameter">out_charset</code>.
       </p>
      </div>
     </dd>

    
    
     <dt>
<code class="parameter">str</code></dt>

     <dd>

      <p class="para">
       The string to be converted.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.iconv-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the converted string or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.iconv-changelog">
   <h3 class="title">Changelog</h3>
   <p class="para">
    <table class="doctable informaltable">
     
      <thead>
       <tr>
        <th>Version</th>
        <th>Description</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>5.4.0</td>
        <td>
         Since this version, the function returns <strong><code>FALSE</code></strong> on illegal characters,
         unless <em>//IGNORE</em> is specified in output charset.
         Before, it returned partial output string.
        </td>
       </tr>

    </tbody>
   
  </table>

 </p>
</div>


 <div class="refsect1 examples" id="refsect1-function.iconv-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2982">
    <p><strong>Example #1 <span class="function"><strong>iconv()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$text&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;the&nbsp;Euro&nbsp;symbol&nbsp;'€'."</span><span style="color: #007700">;<br /><br />echo&nbsp;</span><span style="color: #DD0000">'Original&nbsp;:&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">'TRANSLIT&nbsp;:&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iconv</span><span style="color: #007700">(</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"ISO-8859-1//TRANSLIT"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">'IGNORE&nbsp;&nbsp;&nbsp;:&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iconv</span><span style="color: #007700">(</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"ISO-8859-1//IGNORE"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">'Plain&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iconv</span><span style="color: #007700">(</span><span style="color: #DD0000">"UTF-8"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"ISO-8859-1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><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 &#039;€&#039;.
TRANSLIT : This is the Euro symbol &#039;EUR&#039;.
IGNORE   : This is the Euro symbol &#039;&#039;.
Plain    :
Notice: iconv(): Detected an illegal character in input string in .\iconv-example.php on line 7
</pre></div>
    </div>
   </div>
  </p>
 </div>




</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.iconv-substr.html">iconv_substr</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ob-iconv-handler.html">ob_iconv_handler</a></div>
 <div class="up"><a href="ref.iconv.html">iconv Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>