Display complete umlaut with PHP text limit function
<p>I have the following function that replaces strings with more than 32 characters with "...". My problem is that if an umlaut falls in the range of 29th - 33rd character, it is represented by a weird character. How do I alter the function to show the entire umlaut without breaking it, despite what number length I place in the variable $length?</p>

<p>For example, there are 31 characters ahead of für, but using the function below, it gives 31 characters plus f�...</p>

<pre><code>function textLimit($string, $length, $replacer = '...')
{
  if(strlen($string) &gt; $length)
  return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;

  return $string;
}
</code></pre>
