Hello, fellow Yii people!
Is there any way to show special characters in the page title?
when I use
$this->pageTitle=Yii::app()->name . ' - Campañas';
it shows in the title:
Campañas
and when I use
$this->pageTitle=Yii::app()->name . ' - Campañas';
it throws me this error:
htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument
Is there any way to show correctly the title without modifying the core?
Thanks for the help 
outrage
(Site Sense Web)
2
Just a guess because I haven’t come across this before.
Are you setting the character encoding before the <title>?
// HTML
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
// HTML5
<meta charset="utf-8">
// XHTML/XML
<?xml version="1.0" encoding="utf-8"?>
Hello outrage
Yes, the charset is on the layout, but I think that the problem is more between the view and the framework.
Solved!
Just for the record, I’ll state what I did.
- encode the title as follows:
$this->pageTitle=Yii::app()->name . utf8_encode(' - Campañas');
- set the page encoding to UTF-8
<meta charset="UTF-8">
- finally AND MOST IMPORTANT in the <title> tag, remove the
CHtml::encode
method.
that did the trick!
c.harms
(C Harms Ensink)
5
I know this is an old Thread, but since I just stumbled upon it through the Forum Search, I guess others might as well. So:
Do NOT do this! Do not remove the CHtml::encode() (or Html::encode()), unless you know exactly what you are doing.
Why this could be potentially dangerous is explained very well in this answer on Stackoverflow:
stackoverflow[dot]com/a/30765345/4711348
(I’m sorry, this is one of my first posts, so I’m not allowed to properly embed links in posts yet.)
Cheers
Christoph