src/HTTP2.php
public function negotiateCharset($supported, $default = 'ISO-8859-1')
    {
        $supp = array();
        foreach ($supported as $charset) {
            $supp[strtolower($charset)] = $charset;
        }

        if (!count($supp)) {
            return $default;
        }

        if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
            $match = $this->matchAccept(
                $_SERVER['HTTP_ACCEPT_CHARSET'],
                $supp
            );

            if (!is_null($match)) {
                return $match;
            }
        }

        return $default;
    }
public function negotiateCharset($supported, $default = 'ISO-8859-1')
    {
        $supp = array();
        foreach ($supported as $charset) {
            $supp[strtolower($charset)] = $charset;
        }

        if (!count($supp)) {
            return $default;
        }

        if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) {
            $match = $this->matchAccept(
                $_SERVER['HTTP_ACCEPT_CHARSET'],
                $supp
            );

            if (!is_null($match)) {
                return $match;
            }
        }

        return $default;
    }
Negotiates charset with the user's browser through the Accept-Charset
HTTP header.

Quality factors in the Accept-Charset: header are supported, e.g.:
Accept-Language: en-UK;q=0.7, en-US;q=0.6, no, dk;q=0.8

<code>
require_once 'HTTP2.php';
$http = new HTTP2();
$charsets = array(
'UTF-8',
'ISO-8859-1',
);
$charset = $http->negotiateCharset($charsets);
</code>

@param array  $supported An array of supported charsets
@param string $default   The default charset to use if none is found.

@return string The negotiated language result or the supplied default.
@author Philippe Jausions <jausions@php.net>