reference/mbstring/functions/mb-convert-encoding.xml
2c17cef6e71c3d85011319cde128cc4edf89a053
...
...
@@ -3,7 +3,7 @@
3
3
<refentry xml:id="function.mb-convert-encoding" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4
4
<refnamediv>
5
5
<refname>mb_convert_encoding</refname>
6
-
<refpurpose>Convert character encoding</refpurpose>
6
+
<refpurpose>Convert a string from one character encoding to another</refpurpose>
7
7
</refnamediv>
8
8

9
9
<refsect1 role="description">
...
...
@@ -15,9 +15,8 @@
15
15
<methodparam choice="opt"><type class="union"><type>array</type><type>string</type><type>null</type></type><parameter>from_encoding</parameter><initializer>&null;</initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
-
Converts the character encoding of <parameter>string</parameter>
19
-
to <parameter>to_encoding</parameter>
20
-
from optionally <parameter>from_encoding</parameter>.
18
+
Converts <parameter>string</parameter> from <parameter>from_encoding</parameter>,
19
+
or the current internal encoding, to <parameter>to_encoding</parameter>.
21
20
If <parameter>string</parameter> is an &array;, all its &string; values will be
22
21
converted recursively.
23
22
</para>
...
...
@@ -31,7 +30,7 @@
31
30
<term><parameter>string</parameter></term>
32
31
<listitem>
33
32
<para>
34
-
The &string; or &array; being encoded.
33
+
The &string; or &array; to be converted.
35
34
</para>
36
35
</listitem>
37
36
</varlistentry>
...
...
@@ -39,7 +38,7 @@
39
38
<term><parameter>to_encoding</parameter></term>
40
39
<listitem>
41
40
<para>
42
-
The type of encoding that <parameter>string</parameter> is being converted to.
41
+
The desired encoding of the result.
43
42
</para>
44
43
</listitem>
45
44
</varlistentry>
...
...
@@ -47,15 +46,20 @@
47
46
<term><parameter>from_encoding</parameter></term>
48
47
<listitem>
49
48
<para>
50
-
Is specified by character code names before conversion. It is either
51
-
an <type>array</type>, or a comma separated enumerated list.
52
-
If <parameter>from_encoding</parameter> is not specified, the internal
53
-
encoding will be used.
54
-
<!-- link to internal encoding info -->
49
+
The current encoding used to interpret <parameter>string</parameter>.
50
+
Multiple encodings may be specified as an &array; or comma separated
51
+
list, in which case the correct encoding will be guessed using the
52
+
same algorithm as <function>mb_detect_encoding</function>.
55
53
</para>
56
54
<para>
57
-
See <link linkend="mbstring.supported-encodings">supported
58
-
encodings</link>.
55
+
If <parameter>from_encoding</parameter> is omitted or &null;, the
56
+
<link linkend="ini.mbstring.internal-encoding">mbstring.internal_encoding setting</link>
57
+
will be used if set, otherwise the <link linkend="ini.default-charset">default_charset setting</link>.
58
+
</para>
59
+
<para>
60
+
See <link linkend="mbstring.supported-encodings">supported encodings</link>
61
+
for valid values of <parameter>to_encoding</parameter>
62
+
and <parameter>from_encoding</parameter>.
59
63
</para>
60
64
</listitem>
61
65
</varlistentry>
...
...
@@ -92,6 +96,16 @@
92
96
</thead>
93
97
<tbody>
94
98
<row>
99
+
<entry>8.2.0</entry>
100
+
<entry>
101
+
<function>mb_convert_encoding</function> will no longer return
102
+
the following non text encodings:
103
+
<literal>"Base64"</literal>, <literal>"QPrint"</literal>,
104
+
<literal>"UUencode"</literal>, <literal>"HTML entities"</literal>,
105
+
<literal>"7 bit"</literal> and <literal>"8 bit"</literal>.
106
+
</entry>
107
+
</row>
108
+
<row>
95
109
<entry>8.0.0</entry>
96
110
<entry>
97
111
<function>mb_convert_encoding</function> will now throw a
...
...
@@ -142,7 +156,7 @@ $str = mb_convert_encoding($str, "UTF-7", "EUC-JP");
142
156
/* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */
143
157
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
144
158

145
-
/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
159
+
/* If mbstring.language is "Japanese", "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
146
160
$str = mb_convert_encoding($str, "EUC-JP", "auto");
147
161
?>
148
162
]]>
...
...
@@ -156,6 +170,8 @@ $str = mb_convert_encoding($str, "EUC-JP", "auto");
156
170
<para>
157
171
<simplelist>
158
172
<member><function>mb_detect_order</function></member>
173
+
<member><methodname>UConverter::transcode</methodname></member>
174
+
<member><function>iconv</function></member>
159
175
</simplelist>
160
176
</para>
161
177
</refsect1>
162
178