utf-8,xampp and chtml

I have problem with greek characters and chtml-CActiveForm classess.

For example I write


<?php echo $form->labelEx($model,utf8_encode('τιτλε')); ?>

and there is ���������� -if I write


echo 'τιτλε'

is ok.

I use xampp 1.7.2.I also write chtml::encode().

What is wrong?

I haven’t tried this myself but was wondering if you’re trying to encode a string that is already UTF-8?

A simple function like this may help:


function fixEncoding($x){

  if(mb_detect_encoding($x)=='UTF-8'){

    return $x;

  }else{

    return utf8_encode($x);

  }

}

hi,

can you solve your problem

if yes,please say how?

thanks

you can also use utf-8 meta tag in page head section, i think this resolve your issues.

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

you can also read this article for more details:

you can also use CHtml::encode(value);

please read this article for more information:

http://www.yiiframework.com/forum/index.php/topic/19984-model-rules-filter-with-chtmlencode/