<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mbstring.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.mb-convert-encoding.php',
    1 => 'mb_convert_encoding',
    2 => 'Convert a string from one character encoding to another',
  ),
  'up' => 
  array (
    0 => 'ref.mbstring.php',
    1 => 'Multibyte String Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.mb-convert-case.php',
    1 => 'mb_convert_case',
  ),
  'next' => 
  array (
    0 => 'function.mb-convert-kana.php',
    1 => 'mb_convert_kana',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mbstring/functions/mb-convert-encoding.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.mb-convert-encoding" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_convert_encoding</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mb_convert_encoding</span> &mdash; <span class="dc-title">Convert a string from one character encoding to another</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mb-convert-encoding-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mb_convert_encoding</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$to_encoding</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$from_encoding</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Converts <code class="parameter">string</code> from <code class="parameter">from_encoding</code>,
   or the current internal encoding, to <code class="parameter">to_encoding</code>.
   If <code class="parameter">string</code> is an <a href="language.types.array.php" class="link">Array</a>, all its <a href="language.types.string.php" class="link">String</a> values will be
   converted recursively.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mb-convert-encoding-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       The <a href="language.types.string.php" class="link">String</a> or <a href="language.types.array.php" class="link">Array</a> to be converted.
      </p>
     </dd>
    
    
     <dt><code class="parameter">to_encoding</code></dt>
     <dd>
      <p class="para">
       The desired encoding of the result.
      </p>
     </dd>
    
    
     <dt><code class="parameter">from_encoding</code></dt>
     <dd>
      <p class="para">
       The current encoding used to interpret <code class="parameter">string</code>.
       Multiple encodings may be specified as an <a href="language.types.array.php" class="link">Array</a> or comma separated
       list, in which case the correct encoding will be guessed using the
       same algorithm as <span class="function"><a href="function.mb-detect-encoding.php" class="function">mb_detect_encoding()</a></span>.
      </p>
      <p class="para">
       If <code class="parameter">from_encoding</code> is omitted or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the
       <a href="mbstring.configuration.php#ini.mbstring.internal-encoding" class="link">mbstring.internal_encoding setting</a>
       will be used if set, otherwise the <a href="ini.core.php#ini.default-charset" class="link">default_charset setting</a>.
      </p>
      <p class="para">
       See <a href="mbstring.supported-encodings.php" class="link">supported encodings</a>
       for valid values of <code class="parameter">to_encoding</code>
       and <code class="parameter">from_encoding</code>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mb-convert-encoding-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   The encoded <a href="language.types.string.php" class="link">String</a> or <a href="language.types.array.php" class="link">Array</a> on success, Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben..
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.mb-convert-encoding-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
   As of PHP 8.0.0, a <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> is thrown if the
   value of <code class="parameter">to_encoding</code> or
   <code class="parameter">from_encoding</code> is an invalid encoding.
   Prior to PHP 8.0.0, a <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> was emitted instead.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.mb-convert-encoding-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.2.0</td>
      <td>
       <span class="function"><strong>mb_convert_encoding()</strong></span> will no longer return
       the following non text encodings:
       <code class="literal">&quot;Base64&quot;</code>, <code class="literal">&quot;QPrint&quot;</code>,
       <code class="literal">&quot;UUencode&quot;</code>, <code class="literal">&quot;HTML entities&quot;</code>,
       <code class="literal">&quot;7 bit&quot;</code> and <code class="literal">&quot;8 bit&quot;</code>.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <span class="function"><strong>mb_convert_encoding()</strong></span> will now throw a
       <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> when
       <code class="parameter">to_encoding</code> is passed an invalid encoding.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <span class="function"><strong>mb_convert_encoding()</strong></span> will now throw a
       <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> when
       <code class="parameter">from_encoding</code> is passed an invalid encoding.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">from_encoding</code> is nullable now.
      </td>
     </tr>

     <tr>
      <td>7.2.0</td>
      <td>
       This function now also accepts an <a href="language.types.array.php" class="link">Array</a> as <code class="parameter">string</code>.
       Formerly, only <a href="language.types.string.php" class="link">String</a>s have been supported.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.mb-convert-encoding-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>mb_convert_encoding()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="annotation-non-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Convert internal character encoding to SJIS */<br /></span><span style="color: #0000BB">$str </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #DD0000">"SJIS"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Convert EUC-JP to UTF-7 */<br /></span><span style="color: #0000BB">$str </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #DD0000">"UTF-7"</span><span style="color: #007700">, </span><span style="color: #DD0000">"EUC-JP"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */<br /></span><span style="color: #0000BB">$str </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #DD0000">"UCS-2LE"</span><span style="color: #007700">, </span><span style="color: #DD0000">"JIS, eucjp-win, sjis-win"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* If mbstring.language is "Japanese", "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */<br /></span><span style="color: #0000BB">$str </span><span style="color: #007700">= </span><span style="color: #0000BB">mb_convert_encoding</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #DD0000">"EUC-JP"</span><span style="color: #007700">, </span><span style="color: #DD0000">"auto"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mb-convert-encoding-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.mb-detect-order.php" class="function" rel="rdfs-seeAlso">mb_detect_order()</a> - Set/Get character encoding detection order</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> - Konvertiert eine Zeichenkette von einem Zeichensatz in einen anderen</span></li>
   </ul>
  </p>
 </div>


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