title: preg_match unicode parsing
body: <p>I want to match a sub set of unicode/UTF-8 chars, (marked in yellow here <a href="http://solomon.ie/unicode/" rel="nofollow">http://solomon.ie/unicode/</a>), from my research I came up with this:</p>
  
  <pre><code>// ensure it's valid unicode / get rid of invalid UTF8 chars
  $text = iconv("UTF-8","UTF-8//IGNORE",$text);
  
  // and just allow a basic english...ish.. chars through - no controls, chinese etc
  $match_list = "\x{09}\x{0a}\x{0d}\x{20}-\x{7e}"; // basic ascii chars plus CR,LF and TAB 
  $match_list .= "\x{a1}-\x{ff}"; // extended latin 1 chars excluding control chars
  $match_list .= "\x{20ac}"; // euro symbol
  
  if (preg_match("/[^$match_list]/u", $text) )
      $error_text_array[] = "&lt;b&gt;INVALID UNICODE characters&lt;/b&gt;";
  </code></pre>
  
  <p>Testing seems to show it works as expected, but as a newbie to uniocde I'd be grateful if anyone here can spot any vulnerabilities I've overlooked.</p>
  
  <p>Can I confirm that the hex ranges are matching unicode code points as opposed to the actual hex value (ie x20ac instead of xe282ac for the Euro symbol is correct)?</p>
  
  <p>And can I mix literal characters and hex values like preg_match("/[^0-9\x{20ac}]/u", $text)?</p>
  
  <p>Thanks,
  Kevin</p>
  
  <p>Note, I tried this question before but it was closed off - "better suited to codereview.stackexchange.com", but no response there so hope it's ok to try again in a much more concise format.</p>