<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.utf8-decode.php',
    1 => 'utf8_decode',
    2 => 'Converts a string from UTF-8 to ISO-8859-1, replacing invalid or unrepresentable
   characters',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'prev' => 
  array (
    0 => 'function.ucwords.php',
    1 => 'ucwords',
  ),
  'next' => 
  array (
    0 => 'function.utf8-encode.php',
    1 => 'utf8_encode',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/utf8-decode.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.utf8-decode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">utf8_decode</h1> 
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">utf8_decode</span> &mdash; <span class="dc-title">
   Converts a string from UTF-8 to ISO-8859-1, replacing invalid or unrepresentable
   characters
  </span></p>

 </div>

 <div id="function.utf8-decode-refsynopsisdiv">
  <div class="warning"><strong class="warning">Увага</strong><p class="simpara">Ця функція
<em>ЗАСТАРІЛА</em>, починаючи з PHP 8.2.0. Вкрай не рекомендується
на неї покладатися.</p></div>
 </div>

 <div class="refsect1 description" id="refsect1-function.utf8-decode-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
   <span class="methodname"><strong>utf8_decode</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   This function converts the string <code class="parameter">string</code> from the
   <code class="literal">UTF-8</code> encoding to <code class="literal">ISO-8859-1</code>. Bytes
   in the string which are not valid <code class="literal">UTF-8</code>, and
   <code class="literal">UTF-8</code> characters which do not exist in
   <code class="literal">ISO-8859-1</code> (that is, code points above
   <code class="literal">U+00FF</code>) are replaced with <code class="literal">?</code>.
  </p>

  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    Many web pages marked as using the <code class="literal">ISO-8859-1</code> character
    encoding actually use the similar <code class="literal">Windows-1252</code> encoding,
    and web browsers will interpret <code class="literal">ISO-8859-1</code> web pages as
    <code class="literal">Windows-1252</code>. <code class="literal">Windows-1252</code> features
    additional printable characters, such as the Euro sign
    (<code class="literal">€</code>) and curly quotes (<code class="literal">“</code>
    <code class="literal">”</code>), instead of certain <code class="literal">ISO-8859-1</code>
    control characters. This function will not convert such
    <code class="literal">Windows-1252</code> characters correctly. Use a different
    function if <code class="literal">Windows-1252</code> conversion is required.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.utf8-decode-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       A UTF-8 encoded string.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.utf8-decode-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the ISO-8859-1 translation of <code class="parameter">string</code>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.utf8-decode-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.2.0</td>
       <td>
        This function has been deprecated.
       </td>
      </tr>

      <tr>
       <td>7.2.0</td>
       <td>
        This function has been moved from the XML extension to the core of PHP.
        In previous versions, it was only available if the XML extension was installed.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.utf8-decode-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="example-1">
   <p><strong>Приклад #1 Basic examples</strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Convert the string 'Zoë' from UTF-8 to ISO 8859-1<br /></span><span style="color: #0000BB">$utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\x5A\x6F\xC3\xAB"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">utf8_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Invalid UTF-8 sequences are replaced with '?'<br /></span><span style="color: #0000BB">$invalid_utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\xC3"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">utf8_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$invalid_utf8_string</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Characters which don't exist in ISO 8859-1, such as<br />// '€' (Euro Sign) are also replaced with '?'<br /></span><span style="color: #0000BB">$utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\xE2\x82\xAC"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">utf8_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Поданий вище приклад
виведе:</p></div>
   <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">5a6feb
string(1) &quot;?&quot;
string(1) &quot;?&quot;</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 notes" id="refsect1-function.utf8-decode-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <strong>Deprecation and alternatives</strong><br />
   <p class="para">
    This function is <em>deprecated</em> as of PHP 8.2.0,
    and will be removed in a future version. Existing uses should be checked
    and replaced with appropriate alternatives.
   </p>
   <p class="para">
    Similar functionality can be achieved with <span class="function"><a href="function.mb-convert-encoding.php" class="function">mb_convert_encoding()</a></span>,
    which supports ISO-8859-1 and many other character encodings.
    <div class="informalexample">
     <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\xC3\xAB"</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'ë' (e with diaeresis) in UTF-8<br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">, </span><span style="color: #DD0000">'ISO-8859-1'</span><span style="color: #007700">, </span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\xCE\xBB"</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'λ' (Greek lower-case lambda) in UTF-8<br /></span><span style="color: #0000BB">$iso8859_7_string </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">, </span><span style="color: #DD0000">'ISO-8859-7'</span><span style="color: #007700">, </span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_7_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\xE2\x82\xAC"</span><span style="color: #007700">; </span><span style="color: #FF8000">// '€' (Euro sign) in UTF-8 (not present in ISO-8859-1)<br /></span><span style="color: #0000BB">$windows_1252_string </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">, </span><span style="color: #DD0000">'Windows-1252'</span><span style="color: #007700">, </span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$windows_1252_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

     <p class="para">Поданий вище приклад
виведе:</p>
     <div class="example-contents screen">
<div class="annotation-interactive notescode"><pre class="notescode">eb
eb
80</pre>
</div>
     </div>
    </div>
   </p>
   <p class="para">
    Other options which may be available depending on the extensions installed are
    <span class="methodname"><a href="uconverter.transcode.php" class="methodname">UConverter::transcode()</a></span> and <span class="function"><a href="function.iconv.php" class="function">iconv()</a></span>.
   </p>
   <p class="para">
    The following all give the same result:
    <div class="informalexample">
     <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\x5A\x6F\xC3\xAB"</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'Zoë' in UTF-8<br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">utf8_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">, </span><span style="color: #DD0000">'ISO-8859-1'</span><span style="color: #007700">, </span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$iso8859_1_string </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">$utf8_string</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">UConverter</span><span style="color: #007700">::</span><span style="color: #0000BB">transcode</span><span style="color: #007700">(</span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">, </span><span style="color: #DD0000">'ISO-8859-1'</span><span style="color: #007700">, </span><span style="color: #DD0000">'UTF8'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

     <p class="para">Поданий вище приклад
виведе:</p>
     <div class="example-contents screen">
<div class="annotation-interactive notescode"><pre class="notescode">5a6feb
5a6feb
5a6feb
5a6feb</pre>
</div>
     </div>
    </div>
    Specifying <code class="literal">&#039;?&#039;</code> as the <code class="literal">&#039;to_subst&#039;</code> option
    to <span class="methodname"><a href="uconverter.transcode.php" class="methodname">UConverter::transcode()</a></span> gives the same result as
    <span class="function"><strong>utf8_decode()</strong></span> for strings which are invalid or which can not
    be represented in ISO 8859-1.
    <div class="informalexample">
     <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$utf8_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"\xE2\x82\xAC"</span><span style="color: #007700">; </span><span style="color: #FF8000">// € (Euro Sign) does not exist in ISO 8859-1<br /></span><span style="color: #0000BB">$iso8859_1_string </span><span style="color: #007700">= </span><span style="color: #0000BB">UConverter</span><span style="color: #007700">::</span><span style="color: #0000BB">transcode</span><span style="color: #007700">(<br />    </span><span style="color: #0000BB">$utf8_string</span><span style="color: #007700">, </span><span style="color: #DD0000">'ISO-8859-1'</span><span style="color: #007700">, </span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">, [</span><span style="color: #DD0000">'to_subst' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'?'</span><span style="color: #007700">]<br />);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$iso8859_1_string</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

     <p class="para">Поданий вище приклад
виведе:</p>
     <div class="example-contents screen">
<div class="annotation-interactive notescode"><pre class="notescode">sring(1) &quot;?&quot;</pre>
</div>
     </div>
    </div>
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.utf8-decode-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.utf8-encode.php" class="function" rel="rdfs-seeAlso">utf8_encode()</a> - Converts a string from ISO-8859-1 to UTF-8</span></li>
    <li><span class="function"><a href="function.mb-convert-encoding.php" class="function" rel="rdfs-seeAlso">mb_convert_encoding()</a> - Convert a string from one character encoding to another</span></li>
    <li><span class="methodname"><a href="uconverter.transcode.php" class="methodname" rel="rdfs-seeAlso">UConverter::transcode()</a> - Convert a string from one character encoding to another</span></li>
    <li><span class="function"><a href="function.iconv.php" class="function" rel="rdfs-seeAlso">iconv()</a> - Convert a string from one character encoding to another</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>