title: PHP: Polish UTF-8 characters displayed incorrectly
body: <p>First of all, hello everyone. I have an issue with PHP and Polish characters, namely "ą Ą ć Ć ę Ę ł Ł ń Ń ó Ó ś Ś ź Ź ż Ż". Below is my example code. I have all the Polish signs in <code>$string</code> variable and their correspondent UTF-8 (hex) represnetation in <code>$utfString</code> variable.</p>
  
  <pre><code>&lt;?php
  header('Content-Type: text/html; charset=utf-8');
  
  $string = 'ą Ą ć Ć ę Ę ł Ł ń Ń ó Ó ś Ś ź Ź ż Ż';
  $utfString = "\xC4\x85 \xC4\x84 \xC4\x87 \xC4\x86 ".
      "\xC4\x99 \xC4\x98 \xC5\x82 \xC5\x81 ".
      "\xC5\x84 \xC5\x83 \xC3\xB3 \xC3\x93 ".
      "\xC5\x9B \xC5\x9A \xC5\xBA \xC5\xB9 ".
      "\xC5\xBC \xC5\xBB";
  
  echo $string;
  var_dump(utf8_encode($string));
  echo $utfString;
  var_dump(utf8_encode($utfString));
  
  ?&gt;
  </code></pre>
  
  <p>The response from the browser presents as here:</p>
  
  <pre><code>� � � � � � � � � � � � � � � � � �
  string '¹ ¥ æ Æ ê Ê ³ £ ñ Ñ ó Ó     ¿ ¯' (length=53)
  ą Ą ć Ć ę Ę ł Ł ń Ń ó Ó ś Ś ź Ź ż Ż
  string 'Ä Ä Ä Ä Ä Ä Å Å Å Å Ã³ Ã Å Å Åº Å¹ Å¼ Å»' (length=89)
  </code></pre>
  
  <p>As you can see outputs are different for those strings. My question is what can I do about it? I was thinking of writing a function that would convert Polish signs in code into their respective UTF-8 representation but that seems far from optimal and rather difficult. Another option would be just to use this UTF-8 representation whenever i would need a Polish sign, but then again, I don't believe it should be this hard and convoluted. What's interesting, when I fetch such a string from database and display it, everything works correctly.</p>
  
  <p>Script file is encoded as UTF-8 without BOM.</p>