title: Detecting server locale encoding with PHP
body: <p>I'm using <code>setlocale</code> and <code>strftime</code> to display localized month names in Brazilian Portuguese:</p>
  
  <pre><code>setlocale(LC_ALL, 'pt_BR');
  $meses = array();
  for($m=1; $m&lt;=12; $m++) {
      $meses[$m] = strftime('%B', mktime(0, 0, 0, $m, 1));
  }
  </code></pre>
  
  <p>This works fine in my dev environment, but on the production server it fails for March (which in Portuguese is "março"). If I <code>utf8_encode</code> the month names, it works on the server, but on my dev environment I get a double-encoded output. I suspect that's because of different locale encodings on each machine. I guess the proper solution would be to install a UTF8 locale setting for pt_BR on the server, but I'd like to avoid that if possible (long story short, the server admins are, er, difficult).</p>
  
  <p>Is it possible to detect the encoding of the current locale from PHP, so I can code around this issue, and make my code work regardless of the locale/encoding settings?</p>