Gihan
Gihan

Reputation: 4283

Yii CHtml textField special characters in value

Code:

CHtml::textField('username', $username, array('class'=>'text'));

If my input field has Å type of special characters the value get disappeared. It solves if I put as htmlentities($username) in value field. But it prints the character as Å

I think it's because the values are get printed by going through CHtml::encode() function.

How should I print the correct value?. Any help please.

Upvotes: 0

Views: 1995

Answers (1)

icefront
icefront

Reputation: 174

Make sure you have in the html head

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

If you work with multibyte strings, this may help:

mb_internal_encoding("UTF-8"); 
mb_regex_encoding('UTF-8');

Put the above 2 lines at the beginning of the code. I always include these at the first 2 lines of my index.php

Upvotes: 1

Related Questions