Habari\MultiByte::detect_bom_encoding PHP Method

detect_bom_encoding() public static method

Detects the encoding being used for a string using the existence of a byte order mark
public static detect_bom_encoding ( $source_contents ) : mixed
$source_contents string. The string whose encoding is being detected
return mixed The source string's detected encoding, or boolean false.
    public static function detect_bom_encoding($source_contents)
    {
        $ret = false;
        if ("þÿ" == substr(0, 2, $source_contents)) {
            $ret = 'UTF-16BE';
        } else {
            if ("ÿþ" == substr(0, 2, $source_contents)) {
                $ret = 'UTF-16LE';
            } else {
                if ("" == substr(0, 3, $source_contents)) {
                    $ret = 'UTF-8';
                }
            }
        }
        return $ret;
    }