Пример #1
0
 /**
  * @dataProvider providerUnicodeIsSeparator
  */
 public function testUnicodeIsSeparator($cp, $rv)
 {
     $this->assertEquals(unicode_is_separator($cp), $rv);
 }
Пример #2
0
/**
 * Returns a string with the first character of each word converted to
 * uppercase and the remainder to lowercase.
 *
 * @param  string $str The UTF-8 encoded string
 * @return string with the first character of each word converted to uppercase
 *                and the remainder to lowercase
 */
function utf8_capwords($str)
{
    $rv = '';
    $state = true;
    while (($char = utf8_get_char($str, $i, $cp)) !== false) {
        if (!($issep = unicode_is_separator($cp))) {
            $_ = $state ? unicode_upcase($cp) : unicode_downcase($cp);
            if ($_ != $cp) {
                $char = utf8_chr($_);
            }
        }
        $state = $issep;
        $rv .= $char;
    }
    return $rv;
}