title: preg_match and UTF-8 in PHP
body: <p>I'm trying to search a UTF8-encoded string using <a href="http://www.php.net/manual/en/function.preg-match.php" rel="noreferrer">preg_match</a>.</p>
  
  <pre><code>preg_match('/H/u', "\xC2\xA1Hola!", $a_matches, PREG_OFFSET_CAPTURE);
  echo $a_matches[0][1];
  </code></pre>
  
  <p>This should print 1, since "H" is at index 1 in the string "¡Hola!". But it prints 2. So it seems like it's not treating the subject as a UTF8-encoded string, even though I'm passing the "u" <a href="http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php" rel="noreferrer">modifier</a> in the regular expression.</p>
  
  <p>I have the following settings in my php.ini, and other UTF8 functions are working:</p>
  
  <pre><code>mbstring.func_overload = 7
  mbstring.language = Neutral
  mbstring.internal_encoding = UTF-8
  mbstring.http_input = pass
  mbstring.http_output = pass
  mbstring.encoding_translation = Off
  </code></pre>
  
  <p>Any ideas?</p>