saegeek
(Abdallah)
December 14, 2009, 6:23pm
1
Hi @ all !
I’m trying to display a text that contains special characters without success.
@the view, if I type:
echo 'éééééé';
i see:
éééééé
on my webpage.
but when i type:
echo CHtml::encode('éééééé');
I don’t see anything (blank page).
Is it due to a line i should add to the main config file ? (like charset or something like)
mikl
(Mike)
December 15, 2009, 10:02am
2
Do you have configured the charset property? If not it defaults to UTF-8. So you should make sure that your application sends the right charset in your HTTP header. Also check here: http://www.yiiframework.com/doc/cookbook/16/
saegeek
(Abdallah)
December 15, 2009, 7:18pm
3
Should I have to add a line in the main config ?
because i would like to setup the application charset as ISO-8859-1
if I write on my template :
<?php echo Yii::app()->charset;?>
I get : ‘UTF-8’
But how i can change this value ?
mikl
(Mike)
December 16, 2009, 11:04am
4
Set it in your configuration (main.php):
return array(
// ...
'charset'=>'ISO-8859-1',
///...
);
saegeek
(Abdallah)
December 16, 2009, 1:11pm
5
OK thanks but i think I solved the special characters problem.
It was due to strtolower() function that does not supports conversion of special characters like ‘é’ or ‘ç’.
I solved this problem with a nice function I found at php.net :
function utf8_strtolower($string) {
return utf8_encode(strtolower(utf8_decode($string)));
}
mikl
(Mike)
December 16, 2009, 1:20pm
6
You could also use mb_strtolower(). See the mentioned cookbook.