title: PHP exec change encoding
body: <p>I need to address UTF-8 filenames with the php exec command. The problem is that the php <code>exec</code> command does not seem to understand utf-8. I use something like this:</p>
  
  <pre><code>echo exec('locale charmap');
  </code></pre>
  
  <p>returns <code>ANSI_X3.4-1968</code></p>
  
  <p>looking at <a href="https://stackoverflow.com/questions/3410424/command-line-character-encoding-from-phps-exec">this</a> SO question, the solution lookes like that:</p>
  
  <pre><code>echo exec('LANG=de_DE.utf8; locale charmap'); 
  </code></pre>
  
  <p>But I still get the same output: <code>ANSI_X3.4-1968</code></p>
  
  <p>On the other hand -  if I execute this php command on the bash command line:</p>
  
  <pre><code>php -r "echo exec('LANG=de_DE.UTF8 locale charmap');"
  </code></pre>
  
  <p>The output is UTF-8.
  So the questions are:</p>
  
  <ol>
  <li>Why is there an different result be executing the php command at bash and at apache_module/web page?</li>
  <li>How to set UTF-8 for <code>exec</code> if it runs inside a website as apache module?</li>
  </ol>