0

I load a UTF-8 encoded json file using php like this:

$string = file_get_contents("_locales/de/messages.json");

When I echo $string I get chars like

delete_context":{ "message": "Löschen" }

where it should be Löschen.

Any idea how to fix that?

John Giotta
  • 16,432
  • 7
  • 52
  • 82
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
  • 1
    Are you setting the encoding on the output page? May be useful - http://stackoverflow.com/questions/2487477/get-file-contents-php – BrynJ Feb 23 '11 at 20:47
  • I have a php file without any html for now, header() does not work, I get a headers already sent error – DarkLeafyGreen Feb 23 '11 at 20:49
  • You could try htmlentities($string) but It should work only in web page. – CappY Feb 23 '11 at 20:51
  • regardless of whether its on a webpage or a terminal, is the browser or the terminal encoding set to UTF-8 as well? – Deep Kapadia Feb 23 '11 at 20:51

1 Answers1

1

Possible resolution: php: file_get_contents encoding problem

Community
  • 1
  • 1
John Giotta
  • 16,432
  • 7
  • 52
  • 82
  • +1 this is a possible reason/solution. It could also be that the OP needs to set the encoding for a page he is outputting on. – Endophage Feb 23 '11 at 20:49