title: PHP basename() and pathinfo() with Multibytes UTF-8 file names
body: <p>I've found that PHP function basename(), as well as pathinfo() have a strange behaviour with multibyte utf-8 names.
  They remove all non-Latin characters until the first Latin character or punctuation sign. However, after that, subsequent non-Latin characters are preserved.</p>
  
  <pre><code>basename("àxà"); // returns "xà", I would expect "àxà" or just "x" instead
  pathinfo("àyà/àxà", PATHINFO_BASENAME); // returns "xà", same as above
  </code></pre>
  
  <p>but curiously the dirname part of pathinfo() works fine:</p>
  
  <pre><code>pathinfo("àyà/àxà", PATHINFO_DIRNAME); // returns "àyà"
  </code></pre>
  
  <p>PHP documentation warns that <a href="http://php.net/manual/en/function.basename.php" rel="noreferrer">basename()</a> and <a href="http://php.net/manual/en/function.pathinfo.php" rel="noreferrer">pathinfo()</a> functions are locale aware, but this does not justify the inconsistency between <code>pathinfo(..., PATHINFO_BASENAME)</code> and <code>pathinfo(..., PATHINFO_DIRNAME)</code>, not to mention the fact that identical non Latin characters are being either discarded or accepted, depending on their position relative to Latin characters.</p>
  
  <p>It sounds like a PHP bug.</p>
  
  <p>Since "basename" checks are really important for security concerns to avoid directoy traversal, is there any reliable basename filter that works decently with unicode input?</p>