Error with utf8 characters and htmlspecialchars in yii

I have a problem with 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 text with utf8 symbol like

<div id="footer">
        Cópyrîgth <br />
</div>

Refresh the page and everything is in order. Nice!;)

And then I try to log in using the utf8 character in the username, for example ádmin , it displays a message:

Error 500

htmlspecialchars(): Invalid multibyte sequence in argument

So, I checked this article on unicode in yii

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

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

Retrying the login again works again (not a failure), but now the footer is broken and shows:

C pyr ght

, " yii", .

?

. php.ini.

AddDefaultCharset UTF-8 .htaccess /MyTest/, , , : DocumentRoot?

+5
7

yii, Unicode , , unicode, utf8. utf8 .

, , . , , .

+6

, , ó î ( ) " utf-8". , ( ) , , ASCII (, , , ). " ", " utf-8".

, <div>, UTF-8. , ISO 8859-1 .

, , . , .

" " . , , . PHP- , -, , htmlspecialchars(), "UTF-8" ( PHP 5.4.0 - "ISO-8859-1"). " " UTF-8 (. , ), htmlspecialchars() .

header('Content-Type: text/html; charset=utf-8');, . , <div> UTF-8 (. , " " ).

, , , - UTF-8, . , . , , UTF-8.

, file . -

main.php: PHP , UTF-8 Unicode text

od -tx1z, (, | less) . , " " >= 0x80. UTF-8, 2 ( 3 ), all >= 0x80, " " , 0x80.

, , , .

AddDefaultCharset .htaccess, Content-Type: text/html; charset=utf-8 HTTP, Apache ( PHP).

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> , HTTP- ( http- equiv). HTTP- , .

, UTF-8, !

(... , , , , , , ☹)

+3

-, main.php, .

-, , rambo, , UTF8 .

+2

, Yii , , charset Html, utf-8, , plain html Chtml:: encode (Copyright), yii . , Charset utf8.

+1

htmlspecialchars : fooobar.com/questions/340730/...

htmlspecialchars

+1

http://www.utexas.edu/learn/html/spchar.html - Cópyrîght C&#243;pyr&#238;ght

, HTML <meta charset="utf-8">, , .

0

I had this problem too - especially when I tried to display utf text from db. I changed all the collages and types in mysql to utf8-bin - but still do not like it ... then I tried to use all my layouts and views with meta tags, etc ... hell, I even looked at the source code of Japanese sites and inserted this stuff ... NOTHING WORKS _... UNTIL ... I came across THIS message: Yii and UTF8 Display, UTF8 works with mysqli, but not with yii backend It turns out you need to tweak the setting in my main. php in the configuration file under the components. F

0
source

All Articles