mb_detect_encoding
mb_detect_encoding
(PHP 4 >= 4.0.6, PHP 5, PHP 7)
mb_detect_encoding — Detect character encoding
Description
string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] )
Detects character encoding in string str
.
Parameters
-
str
-
The string being detected.
-
encoding_list
-
encoding_list
is list of character encoding. Encoding order may be specified by array or comma separated list string.If
encoding_list
is omitted, detect_order is used. -
strict
-
strict
specifies whether to use the strict encoding detection or not. Default isFALSE
.
Return Values
The detected character encoding or FALSE
if the encoding cannot be detected from the given string.
Examples
Example #1 mb_detect_encoding() example
<?php /* Detect character encoding with current detect_order */ echo mb_detect_encoding($str); /* "auto" is expanded according to mbstring.language */ echo mb_detect_encoding($str, "auto"); /* Specify encoding_list character encoding by comma separated list */ echo mb_detect_encoding($str, "JIS, eucjp-win, sjis-win"); /* Use array to specify encoding_list */ $ary[] = "ASCII"; $ary[] = "JIS"; $ary[] = "EUC-JP"; echo mb_detect_encoding($str, $ary); ?>
See Also
- mb_detect_order() - Set/Get character encoding detection order
© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/function.mb-detect-encoding.php