0

I am developing a php website with the Yii Framework on my local machine:

  • OS X El Capitan
  • PHP 5.6.6
  • Apache/2.4.16

I'm reading some data from database and trying to json_encode them but, when these data contain some accented letters, json_encode fails and returns false.

I also tried to use iconv() to convert the problematic strings but also iconv return false with the following error: Detected an illegal character in input string.

I am sure the problem is not related to database data (I tried to access the same database remotely using a Linux machine with PHP 5.6.7 and the same code works great).

The problem seems to be in some encoding setting I am forgetting.

webpaul
  • 156
  • 4
  • 18
  • You need to post code for people to be able to help. – Eli Stone Jan 14 '16 at 16:08
  • 1
    make sure you're using the **SAME** charset throughout the entire rendering pipeline. there's no point in having (say) utf-8 tables in your db, if the connection to the db is using something else, like latin-1. that'll corrupt the unicode. Read this: http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Marc B Jan 14 '16 at 16:14

0 Answers0