0

I am reading a Serbian UTF8 file with fgetcsv. While on linux

setlocale(LC_ALL,"sr_RS.UTF8")

does the trick, I couldn't get the characters to be loaded properly on Windows. Furthermore, when I try to save the string to the database, it saves only until first non-latin character (this could be related to the application though). My PhpStorm debugger also shows a question mark instead of the non-latin character. Whereas if I define a variable value inside PhpStorm to contain non-latin characters, it shows correctly.

String is displayed wrongly in both browser (Unicode encoding) and PhpStorm debugger. The variable with a Unicode value defined in the code shows correctly on browser/IDE output.

I tried setting headers and using utf8_encode as suggested here, but it didn't work. Thanks.

Community
  • 1
  • 1
srgb
  • 4,783
  • 6
  • 29
  • 45
  • how does it not load properly? and did you check if your php->mysql connection is set for utf8 as well? the ENTIRE pipeline has to be set for utf8, or connected via appropriate translation logic. php may be in utf8, the table/field in mysql may be set for utf8, but that's all pointless if the php->mysql connection is set to something else. – Marc B Jun 03 '14 at 14:27
  • on php level, it displays question marks instead of non latins, both on output (var_dump), and in PhpStorm debugger. I'm currently not concerned with db that much, just trying to get it working on output. php->mysql is handled with Zend. – srgb Jun 03 '14 at 14:41
  • that's not php doing it. that's your output environment. PHP itself doesn't really care what encoding the text is in. but if you echo that text out, then you need to make sure that the display environment (your terminal, your browser, etc...) have been told what the text's encoding is. – Marc B Jun 03 '14 at 14:42
  • browser is set to display in utf8. also, it displays the variable defined inside the code itself correctly (`$foo = "č";`) – srgb Jun 03 '14 at 14:43

0 Answers0