<?php
// Now everything returns as expected.
$str = "foo";
var_dump(
mb_detect_encoding($str, 'UTF-8, UTF-8'), // string(5) "UTF-8"
mb_detect_encoding($str, 'UTF-8, UTF-8', true) // string(5) "UTF-8"
);
$str = "\xf8foo";
var_dump(
mb_detect_encoding($str, 'UTF-8, UTF-8'), // bool(false)
mb_detect_encoding($str, 'UTF-8, UTF-8', true) // bool(false)
);
$str = "foo\xf8";
var_dump(
mb_detect_encoding($str, 'UTF-8, UTF-8'), // bool(false)
mb_detect_encoding($str, 'UTF-8, UTF-8', true) // bool(false)
);
$str = "\xe1\xe9\xf3\xfa";
var_dump(
mb_detect_encoding($str, 'UTF-8, UTF-8'), // bool(false)
mb_detect_encoding($str, 'UTF-8, UTF-8', true) // bool(false)
);
preferences:
59.02 ms | 402 KiB | 5 Q