src/Net/HTTP/Sniffer/Charset.php
public static function getCharsetFromString( $string, $allowed, $default = false )
	{
		if( !$default)
			$default = $allowed[0];
		if( !$string )
			return $default;
		$accepted	= preg_split( '/,\s*/', $string );
		$currentCharset	= $default;
		$currentQuality	= 0;
		foreach( $accepted as $accept )
		{
			if( !preg_match ( self::$pattern, $accept, $matches ) )
				continue;
			$charsetQuality	= isset( $matches[2] ) ? (float) $matches[2] : 1.0;
			if( $charsetQuality > $currentQuality )
			{
				$currentCharset	= strtolower( $matches[1] );
				$currentQuality	= $charsetQuality;
			}
		}
		return $currentCharset;
	}
public static function getCharsetFromString( $string, $allowed, $default = false )
	{
		if( !$default)
			$default = $allowed[0];
		if( !$string )
			return $default;
		$accepted	= preg_split( '/,\s*/', $string );
		$currentCharset	= $default;
		$currentQuality	= 0;
		foreach( $accepted as $accept )
		{
			if( !preg_match ( self::$pattern, $accept, $matches ) )
				continue;
			$charsetQuality	= isset( $matches[2] ) ? (float) $matches[2] : 1.0;
			if( $charsetQuality > $currentQuality )
			{
				$currentCharset	= strtolower( $matches[1] );
				$currentQuality	= $charsetQuality;
			}
		}
		return $currentCharset;
	}
public static function getCharsetFromString ( $ string , $ allowed , $ default = false ) { if ( ! $ default ) $ default = $ allowed [ 0 ] ; if ( ! $ string ) return $ default ; $ accepted = preg_split ( '/,\s*/' , $ string ) ; $ currentCharset = $ default ; $ currentQuality = 0 ; foreach ( $ accepted as $ accept ) { if ( ! preg_match ( self :: $ pattern , $ accept , $ matches ) ) continue ; $ charsetQuality = isset ( $ matches [ 2 ] ) ? ( float ) $ matches [ 2 ] : 1.0 ; if ( $ charsetQuality > $ currentQuality ) { $ currentCharset = strtolower ( $ matches [ 1 ] ) ; $ currentQuality = $ charsetQuality ; } } return $ currentCharset ; }
Returns prefered allowed and accepted Character Set from String.
@access		public
@static
@param		array	$allowed		Array of Character Sets supported and allowed by the Application
@param		string	$default		Default Character Sets supported and allowed by the Application
@return		string
Returns prefered allowed and accepted Character Set from String .