The problem with UTF-8 Byte Order Mark, or in the Cyrillic krakazyaba

Faced with the problem of incorrect display of Cyrillic fonts in the browser, but rather the browser was incorrectly identifying the encoding. A brief analysis showed that this disadvantage appears only when you enable the plugin ZF debug. Throwing a look at the page source I saw that the styles and scripts for your plugin connects immediately after the opening tag <head>, i.e. to of the meta tag with information about the encoding of the page that, apparently, is not quite correct.



To remedy the situation, you need to edit the file library\ZFDebug\Controller\Plugin\Debug.php the following(selected in black)

protected function _headerOutput() {
$collapsed = isset($_COOKIE['ZFDebugCollapsed']) ? $_COOKIE['ZFDebugCollapsed'] : 0;

return ('
<style type="text/css" media="screen">
...
</script> </head>'
);
}


protected function _output($html)
{
...
$response->setBody(preg_replace('/(<\/head>)/i', '$1' . $this->_headerOutput(), $response->getBody()));
...
}


Everything is now <meta http-equiv="content-type" content="text/html; charset=utf-8" /> will be immediately after the opening tag <head>.

PS the Problem is solved if you specify a BOM at the beginning of the file, but, for example, PHP Storm can not(at the moment) to save it. However, BOM is not required for browser-based applications, even redundant, on the basis of the document "Use of BOM is neither required nor recommended for UTF-8"
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Briefly on how to make your Qt geoservice plugin

Database replication PostgreSQL-based SymmetricDS

Yandex.Widget + adjustIFrameHeight + MooTools