public static function getContentCharset(RequestInterface $request): string
    {
        $contentType = $request->getHeaderLine('Content-Type');
        if (preg_match('/[^;]+; ?charset=(?P<charset>[^;]+);?.*/', $contentType, $matches)) {
            return $matches['charset'];
        }

        return '';
    }
public static function getContentCharset(RequestInterface $request): string
    {
        $contentType = $request->getHeaderLine('Content-Type');
        if (preg_match('/[^;]+; ?charset=(?P<charset>[^;]+);?.*/', $contentType, $matches)) {
            return $matches['charset'];
        }

        return '';
    }
public static function getContentCharset ( RequestInterface $ request ) : string { $ contentType = $ request -> getHeaderLine ( 'Content-Type' ) ; if ( preg_match ( '/[^;]+; ?charset=(?P<charset>[^;]+);?.*/' , $ contentType , $ matches ) ) { return $ matches [ 'charset' ] ; } return '' ; }
Extract the charset from the content type header if available

@param RequestInterface $request
@return string the found charset or empty string if none
Extract the charset from the content type header if available