0

I wrote this short code to output the ping. But there are umlauts in my output, since i am running this command on a german windows 7 computer, these umlauts (ö,ä,ü) are always visible as ? in the output.

So i tried to set the locale to de_DE.UTF-8 but this did not helped either.

<?php
    header('Content-type: text/plain; charset=utf-8');
    $locale=    'de_DE.UTF-8';
    setlocale   (LC_ALL,    $locale);
    putenv      ('LC_ALL='.$locale);

    $result = shell_exec('ping www.google.de');

    echo $result;
?>

Snippet from my output:

Ping wird ausgef�hrt f�r www.google.de [173.194.112.248] mit 32 Bytes Daten:

deceze
  • 510,633
  • 85
  • 743
  • 889
Black
  • 18,150
  • 39
  • 158
  • 271
  • http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Amarnasan Nov 17 '15 at 12:30
  • What data are you receiving? Maybe it's need to be decoded as UTF-8? – S.Pols Nov 17 '15 at 12:34
  • See my updated question pls. – Black Nov 17 '15 at 12:47
  • Well, the problem is that your shell isn't actually returning UTF-8 encoded data. The question is what encoding *does* it return and possibly how to tell it to return something else. I don't know how to do this in Windows, but good luck. – deceze Nov 17 '15 at 12:53
  • Why would ping command via shell_exec output utf8 encoding anyway? – Phil Nov 17 '15 at 13:09

0 Answers0