title: Cron Job on Unix SSH server : UTF-8 encoding?
body: <p>Running in PHP 5, I have tried the following two commands to upload from a ISO-8859-1 string to a UTF-8 database that links to UTF-8 web pages:</p>
  
  <pre><code>$data[] = utf8_encode((string)$child);
  </code></pre>
  
  <p>... or:</p>
  
  <pre><code>$data[] = convertToUtf8((string)$child);
  
  function convertToUtf8($text) {
  //  cURL('http://'.$url);
  
      preg_match('/&lt;meta.*?charset=(|\")(.*?)("|\")/i', $html, $matches);
  
      $charset = $matches[2];
  
      if($charset)
          return mb_convert_encoding($text, 'UTF-8', $charset);
      else
          return $text;
  }   
  </code></pre>
  
  <p>If I execute the PHP script directly by accessing the file from the browser, either one of these works like a charm : the « é » imported is its nice French self. HOWEVER, when I try to execute the same script from a Unix terminal SSH (cron job OR command line), it does not convert the code and so the « é » shows up as « Ã© ».</p>
  
  <p>Any ideas?? I've tried deleting the cron job and replacing the script to make sure the code was going through. This is getting maddening!</p>
  
  <p>Update - the solution</p>
  
  <p>It turns out this particular functionality needs a later version of PHP. Executing it in the Terminal with the following command (and writing the command as such in the cron job) takes care of the problem:</p>
  
  <pre><code>php5.4 xmluploader.php
  </code></pre>