public function convert(string $string): string
    {
        if ($this->encoding === null) {
            $this->encoding = $this->getEncoding($string);
        }

        if ($this->encoding === self::UTF16BE) {
            $string = mb_convert_encoding($string, "UTF-8", "UTF-16BE");
        }

        if ($this->encoding === self::UTF16LE) {
            $string = mb_convert_encoding($string, "UTF-8", "UTF-16LE");
        }

        return $string;
    }
public function convert(string $string): string
    {
        if ($this->encoding === null) {
            $this->encoding = $this->getEncoding($string);
        }

        if ($this->encoding === self::UTF16BE) {
            $string = mb_convert_encoding($string, "UTF-8", "UTF-16BE");
        }

        if ($this->encoding === self::UTF16LE) {
            $string = mb_convert_encoding($string, "UTF-8", "UTF-16LE");
        }

        return $string;
    }
public function convert ( string $ string ) : string { if ( $ this -> encoding === null ) { $ this -> encoding = $ this -> getEncoding ( $ string ) ; } if ( $ this -> encoding === self :: UTF16BE ) { $ string = mb_convert_encoding ( $ string , "UTF-8" , "UTF-16BE" ) ; } if ( $ this -> encoding === self :: UTF16LE ) { $ string = mb_convert_encoding ( $ string , "UTF-8" , "UTF-16LE" ) ; } return $ string ; }
Read some data, remove any BOM found, and convert to UTF-8.

@param string $string The data to read/convert

@return string
Read some data remove any BOM found and convert to UTF - 8 .