How do I recognise lowercase characters in a UTF-8 string?

52 views Asked by At

In PHP, I want to process a given string in UTF-8 format in a way that lowercase characters are treated differently from uppercase characters.

With most strings, ctype_lower() works fine. But it doesn't recognize e.g. German umlauts.

Which other PHP function can I use for detecting lowercase characters in a UTF-8 string?

This is my PHP function which I use to create a string with small caps.

function small_caps(

$string)
{
   $buf = "";

   $results = array();
   $results = mb_str_split($string);


   for ($i = 0; $i < count($results); $i++)
   {
      $char = $results[$i];

      if (ctype_lower($char))
         $buf .= "<small>$char</small>";
      else
         $buf .= "<b>$char</b>";
   }

   // remove redundancies
   $buf = str_replace("</small><small>","",$buf);

   return "<span style='text-transform:uppercase'>$buf</span>";
}
0

There are 0 answers