mb_detect_encoding Detect character encoding &reftitle.description; stringfalsemb_detect_encoding stringstring arraystringnullencodings&null; boolstrict&false; Detects the most likely character encoding for string string from an ordered list of candidates. Automatic detection of the intended character encoding can never be entirely reliable; without some additional information, it is similar to decoding an encrypted string without the key. It is always preferable to use an indication of character encoding stored or transmitted with the data, such as a "Content-Type" HTTP header. This function is most useful with multibyte encodings, where not all sequences of bytes form a valid string. If the input string contains such a sequence, that encoding will be rejected, and the next encoding checked. The result is not accurate The name of this function is misleading, it performs "guessing" rather than "detection". The guesses are far from accurate, and therefore you cannot use this function to accurately detect the correct character encoding. &reftitle.parameters; string The string being inspected. encodings A list of character encodings to try, in order. The list may be specified as an array of strings, or a single string separated by commas. If encodings is omitted or &null;, the current detect_order (set with the mbstring.detect_order configuration option, or mb_detect_order function) will be used. strict Controls the behaviour when string is not valid in any of the listed encodings. If strict is set to &false;, the closest matching encoding will be returned; if strict is set to &true;, &false; will be returned. The default value for strict can be set with the mbstring.strict_detection configuration option. &reftitle.returnvalues; The detected character encoding, or &false; if the string is not valid in any of the listed encodings. &reftitle.changelog; &Version; &Description; 8.2.0 mb_detect_encoding will no longer return the following non text encodings: "Base64", "QPrint", "UUencode", "HTML entities", "7 bit" and "8 bit". &reftitle.examples; <function>mb_detect_encoding</function> example ]]> &example.outputs; Effect of <parameter>strict</parameter> parameter ]]> &example.outputs; In some cases, the same sequence of bytes may form a valid string in multiple character encodings, and it is impossible to know which interpretation was intended. For instance, among many others, the byte sequence "\xC4\xA2" could be: "Ä¢" (U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS followed by U+00A2 CENT SIGN) encoded in any of ISO-8859-1, ISO-8859-15, or Windows-1252 "ФЂ" (U+0424 CYRILLIC CAPITAL LETTER EF followed by U+0402 CYRILLIC CAPITAL LETTER DJE) encoded in ISO-8859-5 "Ģ" (U+0122 LATIN CAPITAL LETTER G WITH CEDILLA) encoded in UTF-8 Effect of order when multiple encodings match ]]> &example.outputs; &reftitle.seealso; mb_detect_order