Wrong charset from view plugins ZF3

zend-view
#1
     echo $this->headTitle($meta_data->title);
 $this->headMeta()
    ->appendName('description', $meta_data->description);

  $this->headMeta()->setCharset('UTF-8')
     ->appendName('viewport', 'width=device-width, initial-scale=1.0')
     ->appendName('x-ua-compatible', 'ie=edge');
  echo $this->headMeta();

And as result of head view helper I see some wrong charset. Have you some idias, how it can be fixed?
http://joxi.ru/L21RvDNhRV0lRA

1 Like
#2

This has nothing to do with the character set but all HTML attributes are escaped.

You can disable the auto escaping for the view helper: https://docs.zendframework.com/zend-view/helpers/head-meta/#autoescape

Some background information for the topic escaping can be found in the documentation of zend-escaper: https://docs.zendframework.com/zend-escaper/intro/

1 Like
#3

Thank you! But I was seen it in documentation. But it’s not working for me. I was trying:

     $this->headMeta()->setAutoEscape(false)
        ->appendName('description', $meta_data->description);

No result. I have same problem in plugins headScript and headLink:
http://joxi.ru/ZrJpN7bSweQwO2

Maybe ZF have some more global config parameter for escaping?

#4

You must use the latest version of zend-view:

#5

Thank you very much, it was my other mistake, not version.

$this->headMeta()->setAutoEscape(false)
… is working!
But how about over view helpers?: headScript() and headLink() ? It is not a big problem, all scropts and links working. Is it better to use autoescaping? I need to set autoescape option to false for each other by some specific method? Have I some other way?

#6

Yes. (all informations to this topic can be found in the documentation of zend-escaper; see link above)
If you set the meta tag for the Internet Explorer with X-UA-Compatible then you must set the autoescaping to false.

1 Like
#7

Ok, thank you, I undrstood it.