1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 07:42:22 +01:00
Files
archived-doc-ru/reference/mbstring/functions/mb-convert-encoding.xml
Mikhail Alferov afd96f2d1a Update c1f37a6 to En (#1094)
* Update basic.xml to en

* Update properties.xml to en

* Update traits.xml to En

* Update visibility.xml to en

* Update book.xml to en

* Update book.xml to en + infostyle

* Update mb-convert-encoding.xml to en

* Update book.xml to en

* Update mb-convert-encoding.xml nit

* Update preg-replace-callback.xml to en + infostyle

* Update preg-replace-callback.xml to en actually

* Update book.xml to en

* Update simplexml-load-file.xml to en + infostyle

* Update addAttribute.xml to en

* Update addChild.xml to en

* Update construct.xml to en

* Update getName.xml to en

* Update book.xml to en

* Update xml-parse.xml to en + infostyle

* Update book.xml to en

* Update isvalid.xml to en

* Update book.xml to en
2025-07-29 02:53:50 +03:00

205 lines
8.2 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: mch Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.mb-convert-encoding" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mb_convert_encoding</refname>
<refpurpose>Преобразовывает строку из одной кодировки символов в другую</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>array</type><type>string</type><type>false</type></type><methodname>mb_convert_encoding</methodname>
<methodparam><type class="union"><type>array</type><type>string</type></type><parameter>string</parameter></methodparam>
<methodparam><type>string</type><parameter>to_encoding</parameter></methodparam>
<methodparam choice="opt"><type class="union"><type>array</type><type>string</type><type>null</type></type><parameter>from_encoding</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Функция преобразовывает значение параметра <parameter>string</parameter>
из кодировки <parameter>from_encoding</parameter>, или текущей внутренней кодировки,
в кодировку <parameter>to_encoding</parameter>.
При передаче в параметр <parameter>string</parameter> массива (&array;)
функция рекурсивно преобразует каждое &string;-значение массива.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
Строка (&string;) или массив (&array;), для преобразования.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>to_encoding</parameter></term>
<listitem>
<para>
Кодировка результата.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>from_encoding</parameter></term>
<listitem>
<para>
Текущая кодировка для интерпретации строки <parameter>string</parameter>.
Набор кодировок указывают в массиве (&array;) или в строке со списком значений через запятую,
тогда PHP попытается определить правильную кодировку по тому же алгоритму,
которым определяет кодировку функция <function>mb_detect_encoding</function>.
</para>
<para>
При пропуске параметра <parameter>from_encoding</parameter> или установке значения &null;
функция опирается на настройку директивы
<link linkend="ini.mbstring.internal-encoding">mbstring.internal_encoding</link>,
если директиву установили, иначе на значение директивы <link linkend="ini.default-charset">default_charset</link>.
</para>
<para>
Допустимые значения параметров <parameter>to_encoding</parameter> и <parameter>from_encoding</parameter>
перечисляет страница «<link linkend="mbstring.supported-encodings">Поддерживаемые кодировки символов</link>».
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Функция возвращает или закодированную строку (&string;),
или закодированный массив (&array;),&return.falseforfailure;.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Начиная с PHP 8.0.0 функция выбросит ошибку <classname>ValueError</classname>,
если значением параметра <parameter>to_encoding</parameter>
или параметра <parameter>from_encoding</parameter> окажется недопустимая кодировка.
До PHP 8.0.0 вместо этого выдавалась ошибка уровня <constant>E_WARNING</constant>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>8.2.0</entry>
<entry>
Функция <function>mb_convert_encoding</function> больше не возвращает
следующие нетекстовые кодировки:
<literal>"Base64"</literal>, <literal>"QPrint"</literal>,
<literal>"UUencode"</literal>, <literal>"HTML entities"</literal>,
<literal>"7 bit"</literal> и <literal>"8 bit"</literal>.
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Функция <function>mb_convert_encoding</function> теперь выбрасывает
ошибку <classname>ValueError</classname>
при передаче в параметр <parameter>to_encoding</parameter> недопустимой кодировки.
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Функция <function>mb_convert_encoding</function> теперь выбрасывает
ошибку <classname>ValueError</classname>
при передаче в параметр <parameter>from_encoding</parameter> недопустимой кодировки.
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Параметр <parameter>from_encoding</parameter> теперь принимает значение &null;.
</entry>
</row>
<row>
<entry>7.2.0</entry>
<entry>
Функция теперь также принимает массив (&array;) как значение параметра <parameter>string</parameter>.
Раньше поддерживались только значения &string;.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример изменения кодировки строки функцией <function>mb_convert_encoding</function></title>
<programlisting role="php" annotations="non-interactive">
<![CDATA[
<?php
/* Преобразовывает строку в кодировку SJIS */
$str = mb_convert_encoding($str, "SJIS");
/* Преобразовывает из кодировки EUC-JP в кодировку UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");
/* Автоматически определяется кодировка среди JIS, eucjp-win, sjis-win, затем преобразовывается в UCS-2LE */
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
/* Если директива mbstring.language равна "Japanese", значение кодировки "auto" будет расширено до "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str = mb_convert_encoding($str, "EUC-JP", "auto");
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mb_detect_order</function></member>
<member><methodname>UConverter::transcode</methodname></member>
<member><function>iconv</function></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
-->