mb_convert_encoding
mb_convert_encoding
Convert a string from one character encoding to another
**mb_convert_encoding** $string string $to_encoding $from_encoding
Converts from ,
or the current internal encoding, to .
If is an array, all its string values will be
converted recursively.
string``from_encoding``to_encoding``string
stringThe string or array to be converted.
to_encodingThe desired encoding of the result.
from_encoding
The current encoding used to interpret .
Multiple encodings may be specified as an array or comma separated
list, in which case the correct encoding will be guessed using the
same algorithm as .
string``mb_detect_encoding
If is omitted or null, the
will be used if set, otherwise the .
`from_encoding`mbstring.internal_encoding settingdefault_charset setting
See
for valid values of
and .
supported encodings`to_encoding``from_encoding`
The encoded string or array on success, return.falseforfailure.
As of PHP 8.0.0, a is thrown if the
value of or
is an invalid encoding.
Prior to PHP 8.0.0, a was emitted instead.
ValueError``to_encoding``from_encoding``E_WARNING
Voorbeeld: example
<?php
/* Convert internal character encoding to SJIS */
$str = mb_convert_encoding($str, "SJIS");
/* Convert EUC-JP to UTF-7 */
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");
/* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
/* If mbstring.language is "Japanese", "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str = mb_convert_encoding($str, "EUC-JP", "auto");
?>
mb_detect_order``UConverter::transcode``iconv