HTML entity of foreign characters

Hello all,

I have a webapp that I’m trying to rewrite using Yii.

There are times that I use Vietnamese characters for my input

With my webapp written from scratch, I submit Đ and it gives me Đ

This doesn’t happen with Yii

Any idea on how to make it spit out the html entity instead of the character?


For it to display the character correctly without the html entity, you may just need to change the character encoding. See Yii::app()->charset (seems to default to utf8) and the Content-Type meta tag in your layout file.

The way to encode them would be CHtml::encode() (which uses Yii::app()->charset).

If your charset is right and CHtml::encode() doesn’t do it, you may need to use the php htmlentities() which will escape more things than the htmlspecialchars() used by CHtml::encode().

My apologizes. I didn’t realize that my entity got converted into its character

I want the Đ to be displayed as (without spaces)

& # 2 7 2 ;

because that is how most of the data in my database is

I’m not entirely sure what you are trying to do, but it still sounds like the answer would be passing the data through php’s htmlentities()