My framework for each pages does the follow:
ini_set(\'mbstring.internal_encoding\',\'UTF-8\');
ini_set(\'mbstring.func_overload\',7);
header(\'Content-Type:
default_charset ini setting should work for you. PHP always outputs a character encoding by default in the Content-type: header using this setting
Please see https://bugs.php.net/bug.php?id=29983 looks to me like some distros still have the problem
test case
echo "ini_get('default_charset') ". ini_get('default_charset')."<br>";
if (!ini_set('default_charset', 'utf-8')) {
echo "could not set default_charset to utf-8<br>";
}
No, you don't have to.
header('Content-Type: text/html; charset=UTF-8');
sets this for every page already
When it comes to the http-header, you're OK as the other answers explain.
But: There are some functions that are default charset aware
From the description of FILTER_SANITIZE_FULL_SPECIAL_CHARS:
Like htmlspecialchars, this filter is aware of the default_charset and if a sequence of bytes is detected that makes up an invalid character in the current character set then the entire string is rejected resulting in a 0-length string.