title: php filter_var FILTER_FLAG_ENCODE_HIGH
body: <p>I have the fallowing testcase for the php function function_var():</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  $inputvalue = "Ž"; //NUM = 142 on the ASCII extended list
  
  $sanitized = filter_var($inputvalue, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_HIGH);
  
  echo 'The sanitized output: '.$sanitized."\n"; // --&gt; &amp; #197;&amp; #189; (Å ½)
  ?&gt;
  </code></pre>
  
  <p>If you run the above snippet the output is not what I expect to be returned. The Ž is number 142 in the ASCII extended list (see: ascii-code[dot]com). So what I expect to get back is the '&amp; #142;' (string, without the space).</p>
  
  <p>I had <a href="http://gathering.tweakers.net/forum/list_message/39702978" rel="nofollow">help</a> finding out what is going wrong I just dont know how to solve it yet.</p>
  
  <p>If you convert 'Ž' to Hex UTF-8 bytes you get: C5 BD. These hex bytes correspond with the ISO-8859 hex values: Å ½(see: <a href="http://cs.stanford.edu/~miles/iso8859.html" rel="nofollow">http://cs.stanford.edu/~miles/iso8859.html</a>). These 2 characters then get decoded by filter_var to '&amp; #197;&amp; #189;'.</p>
  
  <p>See this onlineconverter!!!: <a href="http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=%C5%BD&amp;mode=char" rel="nofollow">http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=%C5%BD&amp;mode=char</a></p>
  
  <p>So basically what happens: UTF-8 bytes are used to translate them as Latin-1 characters bytes. The converter page says the fallowing: "UTF-8 bytes as Latin-1 characters" is what you typically see when you display a UTF-8 file with a terminal or editor that only knows about 8-bit characters.</p>
  
  <p>I dont think my editor is the problem. I am using a Mac with Coda 2 (UTF-8 as default). The test has also been tested on a html5 page with meta character set to utf-8. Furthermore I am using a defaut XAMPP localhost server. With Firebug in Firefox I also checked if the file was served as UTF-8 (it is).</p>
  
  <p>Anyone got a idea how I can solve this encoding problem?</p>