|
@@ 6405-6444 (lines=40) @@
|
| 6402 |
|
* |
| 6403 |
|
* @return string str with all alphabetic characters converted to lowercase. |
| 6404 |
|
*/ |
| 6405 |
|
public static function strtolower($str, string $encoding = 'UTF-8', bool $cleanUtf8 = false, string $lang = null): string |
| 6406 |
|
{ |
| 6407 |
|
// init |
| 6408 |
|
$str = (string)$str; |
| 6409 |
|
if (!isset($str[0])) { |
| 6410 |
|
return ''; |
| 6411 |
|
} |
| 6412 |
|
|
| 6413 |
|
if ($cleanUtf8 === true) { |
| 6414 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 6415 |
|
// if invalid characters are found in $haystack before $needle |
| 6416 |
|
$str = self::clean($str); |
| 6417 |
|
} |
| 6418 |
|
|
| 6419 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 6420 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 6421 |
|
} |
| 6422 |
|
|
| 6423 |
|
if ($lang !== null) { |
| 6424 |
|
|
| 6425 |
|
if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) { |
| 6426 |
|
self::checkForSupport(); |
| 6427 |
|
} |
| 6428 |
|
|
| 6429 |
|
if (self::$SUPPORT['intl'] === true) { |
| 6430 |
|
|
| 6431 |
|
$langCode = $lang . '-Lower'; |
| 6432 |
|
if (!\in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) { |
| 6433 |
|
\trigger_error('UTF8::strtolower() without intl for special language: ' . $lang, E_USER_WARNING); |
| 6434 |
|
|
| 6435 |
|
$langCode = 'Any-Lower'; |
| 6436 |
|
} |
| 6437 |
|
|
| 6438 |
|
return transliterator_transliterate($langCode, $str); |
| 6439 |
|
} |
| 6440 |
|
|
| 6441 |
|
\trigger_error('UTF8::strtolower() without intl + PHP >= 5.4 cannot handle the "lang"-parameter: ' . $lang, E_USER_WARNING); |
| 6442 |
|
} |
| 6443 |
|
|
| 6444 |
|
return \mb_strtolower($str, $encoding); |
| 6445 |
|
} |
| 6446 |
|
|
| 6447 |
|
/** |
|
@@ 6472-6510 (lines=39) @@
|
| 6469 |
|
* |
| 6470 |
|
* @return string <p>$str with all alphabetic characters converted to uppercase.</p> |
| 6471 |
|
*/ |
| 6472 |
|
public static function strtoupper($str, string $encoding = 'UTF-8', bool $cleanUtf8 = false, string $lang = null): string |
| 6473 |
|
{ |
| 6474 |
|
$str = (string)$str; |
| 6475 |
|
if (!isset($str[0])) { |
| 6476 |
|
return ''; |
| 6477 |
|
} |
| 6478 |
|
|
| 6479 |
|
if ($cleanUtf8 === true) { |
| 6480 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 6481 |
|
// if invalid characters are found in $haystack before $needle |
| 6482 |
|
$str = self::clean($str); |
| 6483 |
|
} |
| 6484 |
|
|
| 6485 |
|
if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
| 6486 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 6487 |
|
} |
| 6488 |
|
|
| 6489 |
|
if ($lang !== null) { |
| 6490 |
|
|
| 6491 |
|
if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) { |
| 6492 |
|
self::checkForSupport(); |
| 6493 |
|
} |
| 6494 |
|
|
| 6495 |
|
if (self::$SUPPORT['intl'] === true) { |
| 6496 |
|
|
| 6497 |
|
$langCode = $lang . '-Upper'; |
| 6498 |
|
if (!\in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) { |
| 6499 |
|
\trigger_error('UTF8::strtoupper() without intl for special language: ' . $lang, E_USER_WARNING); |
| 6500 |
|
|
| 6501 |
|
$langCode = 'Any-Upper'; |
| 6502 |
|
} |
| 6503 |
|
|
| 6504 |
|
return transliterator_transliterate($langCode, $str); |
| 6505 |
|
} |
| 6506 |
|
|
| 6507 |
|
\trigger_error('UTF8::strtolower() without intl + PHP >= 5.4 cannot handle the "lang"-parameter: ' . $lang, E_USER_WARNING); |
| 6508 |
|
} |
| 6509 |
|
|
| 6510 |
|
return \mb_strtoupper($str, $encoding); |
| 6511 |
|
} |
| 6512 |
|
|
| 6513 |
|
/** |