0

strange problem occurs with json_encode(). I have some text in mysql database in russian. The text fields in DB are encoded in utf8-general-ci. when executingecho json_encode($this->result); all the text that is in russian becomes "null"

Any ideas? Thank you in advance

Lev Khomich
  • 2,247
  • 14
  • 18
Vit Kos
  • 5,535
  • 5
  • 44
  • 58
  • 2
    make sure the php file encoding also is in UTF-8 – Fredrik Mar 01 '12 at 13:54
  • Fredrik yes it was @Maerlyn it is the formed array that needs to be encoded, the array is filled with data from the DB. Thanks for the answers gues, the Pekka 's post helped a lot – Vit Kos Mar 01 '12 at 14:10

1 Answers1

2

When json_encode() encounters a string that contains an invalid (= non-UTF-8) character, it drops the entire string silently.

Most likely your database connection is not UTF-8 encoded. See this question on how to fix that.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088