Yii Framework Forum: Utf 8 Decoding Database Data - Yii Framework Forum

Jump to content

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

Utf 8 Decoding Database Data Rate Topic: -----

#1 User is offline   shii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-March 13

Posted 16 March 2013 - 08:23 AM

Hello everybody

I am currently trying to get some utf 8 encoded data from the data base:
For example the String "Message's" is saved as "Message’s"
Without yii when echoing it out it was enough to have the charset set on utf-8.

Yii however echos out "Message’s" although its charset is utf-8 too.
I have already tried php's utf8_decode() function but it just returns some gibberish:
Message�??s


So my Question is: How am i able to echo out the decoded String?
0

#2 User is offline   outrage 

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

Posted 16 March 2013 - 12:32 PM

Make sure your database character set is utf8 -- UTF-8 Unicode

You should be able to convert those characters like this:

<?php
  echo mb_convert_encoding(
    $someData,
    "HTML-ENTITIES",
    "UTF-8"
  );
?>

0

#3 User is offline   shii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-March 13

Posted 19 March 2013 - 10:29 AM

Thanks for your reply, i just tried it but it didn't change anything :/
charset is set to utf8 in the database but it still echos "Message’s"
0

#4 User is offline   shii 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 08-March 13

Posted 19 March 2013 - 10:55 AM

Ok, looks like removing the line 'charset' => 'utf8', in the config file has somehow solved it
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