Problem with the char encoding and unicode

I have a problem with the char encoding in yii.

If I create a new webapp:

     ./Yii-framework/framework/yiic webapp MyTest

Then go to /protected/views/layouts/main.php and change the footer to a text with an utf8 character, for example

    <div id="footer">

			Cópyrîgth <br />


Refresh the page and everything is ok. Nice! ;)

And then I try to log in with an utf8 character in the username, for example ádmin, it crashes saying:

    Error 500

    htmlspecialchars(): Invalid multibyte sequence in argument

So I checked this article about unicode in yii

and then I went to /protected/config/main.php and added this line at the start:

   header('Content-Type: text/html; charset=utf-8');

Retrying the same login again it works (doesn’t crash) but now the footer is broken and shows:


I’ve tried other combinations like explained in the “Unicode in yii” article but none of them make both things work at the same time.

Any ideas for solving this problem?

Note: I can’t change to the php.ini file.

I also tried the AddDefaultCharset UTF-8 option in the .htaccess file and put it in the folder at the /MyTest/ is that the correct folder referred in the article as: your DocumentRoot ?


Did you save your PHP view file /protected/views/layouts/main.php as unicode in your PHP-IDE?

Yup I saved it with eclipse