mb_detect_encoding
(PHP 4 >= 4.0.6, PHP 5, PHP 7)
mb_detect_encoding — Detect character encoding
Description
$str
[, mixed $encoding_list
= mb_detect_order()
[, bool $strict
= FALSE
]] ) : string
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);
?>
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mb-detect-encoding.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.