public function getEncoding(LocalFileNodeInterface $file)
    {
        $cmd = "file --brief --uncompress --mime {$file->getPath()}";

        $process = $this->getProcess($cmd);
        $process->mustRun();

        $result = $process->getOutput();
        if (preg_match('/charset=([^\s]+)/i', $result, $matches)) {
            $this->log(LogLevel::DEBUG, "Found the encoding for '{file}' as '{encoding}'", [
                'file'     => $file,
                'encoding' => $matches[1],
            ]);
            return $matches[1];
        }
        return null;
    }
public function getEncoding(LocalFileNodeInterface $file)
    {
        $cmd = "file --brief --uncompress --mime {$file->getPath()}";

        $process = $this->getProcess($cmd);
        $process->mustRun();

        $result = $process->getOutput();
        if (preg_match('/charset=([^\s]+)/i', $result, $matches)) {
            $this->log(LogLevel::DEBUG, "Found the encoding for '{file}' as '{encoding}'", [
                'file'     => $file,
                'encoding' => $matches[1],
            ]);
            return $matches[1];
        }
        return null;
    }
public function getEncoding ( LocalFileNodeInterface $ file ) { $ cmd = "file --brief --uncompress --mime {$file->getPath()}" ; $ process = $ this -> getProcess ( $ cmd ) ; $ process -> mustRun ( ) ; $ result = $ process -> getOutput ( ) ; if ( preg_match ( '/charset=([^\s]+)/i' , $ result , $ matches ) ) { $ this -> log ( LogLevel :: DEBUG , "Found the encoding for '{file}' as '{encoding}'" , [ 'file' => $ file , 'encoding' => $ matches [ 1 ] , ] ) ; return $ matches [ 1 ] ; } return null ; }
Find the Encoding of a specified file

@param LocalFileNodeInterface $file

@return null|string
@throws ProcessFailedException
Find the Encoding of a specified file