+ Reply to Thread
Results 1 to 6 of 6

Thread: shell_exec, how to make utf8????

  1. #1
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    shell_exec, how to make utf8????

    Ok I am doing a app with shell_exec, and it does not work properly in a swedish OS because someone decided to make the output ascii and not utf8.

    How would I go about replacing all missing charachters with right characters?

    Like if I do:

    $output = shell_exec('ping västtrafik.se);
    echo $output;

    It prints:
    v��sttrafik.se

    $output = shell_exec($cmd);
    $output = utf8_encode($output);
    echo $output;

    it prints:
    vÇÏsttrafik.se

    so how would I get it to print
    västtrafik.se?

  2. #2
    ichwar's Avatar
    ichwar is offline Community Advocate ichwar is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    NC, USA
    Posts
    1,454

    Re: shell_exec, how to make utf8????

    I'm clueless. Sorry.

  3. #3
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: shell_exec, how to make utf8????

    Thought I would fix it by doing

    PHP Code:
    $output str_ireplace("Ǿ""å"$output);
    $output str_ireplace("ÇÏ""ä"$output);
    $output str_ireplace("Çô""ö"$output);
    echo 
    $output
    But no lol...

  4. #4
    ichwar's Avatar
    ichwar is offline Community Advocate ichwar is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    NC, USA
    Posts
    1,454

    Re: shell_exec, how to make utf8????

    no, I've never gotten that to work for me...

  5. #5
    TheMan177 is offline x10 Sophmore TheMan177 is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    179

    Re: shell_exec, how to make utf8????

    Try this, add it before you use shell_exec.

    PHP Code:
    putenv('LANG=en_US.UTF-8'); 

  6. #6
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: shell_exec, how to make utf8????

    If it's the locale that's messing it up, then what TheMan suggested should fix it. But if that doesn't, there's a couple things I can think of.

    This might go without saying, but make sure that the output will be interpreted as UTF-8:

    PHP Code:
    header('Content-Type: text/html; charset=UTF-8'); 
    If it's still messing up, then provided that the echo command modifies it in the same way, and provided that you can regularly output the hostname with no change, this might work:

    PHP Code:
    $host 'www.västtrafik.se';
    $search substr(shell_exec("echo $host"), 0, -1);
    $output shell_exec("ping $host");
    $output str_ireplace($search$host$output); 
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

+ Reply to Thread

Similar Threads

  1. [Game] Make Up A Definition
    By Starshine in forum Forum Games
    Replies: 115
    Last Post: 07-10-2011, 11:23 PM
  2. Replies: 8
    Last Post: 06-19-2008, 09:46 PM
  3. Make $100 Per Week!
    By kesne in forum Earning Money
    Replies: 65
    Last Post: 06-08-2008, 01:31 PM
  4. How to make my sites address with register.com
    By unknownnasa1991 in forum Free Hosting
    Replies: 4
    Last Post: 05-01-2008, 06:12 PM
  5. make life like animation
    By SEÑOR in forum Scripts & 3rd Party Apps
    Replies: 22
    Last Post: 04-09-2006, 06:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers