Yii Framework Forum: utf-8,xampp and chtml - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

utf-8,xampp and chtml Rate Topic: -----

#1 User is offline   dimis283 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 277
  • Joined: 24-January 09

Posted 18 March 2010 - 09:59 AM

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?
Posted Image
0

#2 User is offline   outrage 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 312
  • Joined: 10-November 09
  • Location:Blackpool, United Kingdom

Posted 22 March 2010 - 02:08 PM

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);
  }
}

0

#3 User is offline   imp489 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 10-June 13

Posted 15 June 2013 - 03:39 PM

View Postdimis283, on 18 March 2010 - 09:59 AM, said:

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?

hi,
can you solve your problem
if yes,please say how?
thanks
1

#4 User is offline   Mubashar Iqbal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 18-September 13
  • Location:Lahore

Posted 26 September 2013 - 12:52 AM

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:
http://stackoverflow...iv-content-type
0

#5 User is offline   Mubashar Iqbal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 18-September 13
  • Location:Lahore

Posted 26 September 2013 - 02:35 AM

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

please read this article for more information:

http://www.yiiframew...th-chtmlencode/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users