|
@@ 5918-5960 (lines=43) @@
|
| 5915 |
|
* |
| 5916 |
|
* @return string str with all alphabetic characters converted to lowercase. |
| 5917 |
|
*/ |
| 5918 |
|
public static function strtolower($str, $encoding = 'UTF-8', $cleanUtf8 = false, $lang = null) |
| 5919 |
|
{ |
| 5920 |
|
// init |
| 5921 |
|
$str = (string)$str; |
| 5922 |
|
|
| 5923 |
|
if (!isset($str[0])) { |
| 5924 |
|
return ''; |
| 5925 |
|
} |
| 5926 |
|
|
| 5927 |
|
if ($cleanUtf8 === true) { |
| 5928 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5929 |
|
// if invalid characters are found in $haystack before $needle |
| 5930 |
|
$str = self::clean($str); |
| 5931 |
|
} |
| 5932 |
|
|
| 5933 |
|
if ($encoding !== 'UTF-8') { |
| 5934 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 5935 |
|
} |
| 5936 |
|
|
| 5937 |
|
if ($lang !== null) { |
| 5938 |
|
if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) { |
| 5939 |
|
self::checkForSupport(); |
| 5940 |
|
} |
| 5941 |
|
|
| 5942 |
|
if ( |
| 5943 |
|
self::$SUPPORT['intl'] === true |
| 5944 |
|
&& |
| 5945 |
|
Bootup::is_php('5.4') === true |
| 5946 |
|
) { |
| 5947 |
|
|
| 5948 |
|
$langCode = $lang . '-Lower'; |
| 5949 |
|
if (!in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) { |
| 5950 |
|
$langCode = 'Any-Lower'; |
| 5951 |
|
} |
| 5952 |
|
|
| 5953 |
|
return transliterator_transliterate($langCode, $str); |
| 5954 |
|
} |
| 5955 |
|
|
| 5956 |
|
trigger_error('UTF8::strtolower() without intl + PHP >= 5.4 cannot handle the "strict"-parameter', E_USER_WARNING); |
| 5957 |
|
} |
| 5958 |
|
|
| 5959 |
|
return \mb_strtolower($str, $encoding); |
| 5960 |
|
} |
| 5961 |
|
|
| 5962 |
|
/** |
| 5963 |
|
* Generic case sensitive transformation for collation matching. |
|
@@ 5987-6028 (lines=42) @@
|
| 5984 |
|
* |
| 5985 |
|
* @return string str with all alphabetic characters converted to uppercase. |
| 5986 |
|
*/ |
| 5987 |
|
public static function strtoupper($str, $encoding = 'UTF-8', $cleanUtf8 = false, $lang = null) |
| 5988 |
|
{ |
| 5989 |
|
$str = (string)$str; |
| 5990 |
|
|
| 5991 |
|
if (!isset($str[0])) { |
| 5992 |
|
return ''; |
| 5993 |
|
} |
| 5994 |
|
|
| 5995 |
|
if ($cleanUtf8 === true) { |
| 5996 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 5997 |
|
// if invalid characters are found in $haystack before $needle |
| 5998 |
|
$str = self::clean($str); |
| 5999 |
|
} |
| 6000 |
|
|
| 6001 |
|
if ($encoding !== 'UTF-8') { |
| 6002 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 6003 |
|
} |
| 6004 |
|
|
| 6005 |
|
if ($lang !== null) { |
| 6006 |
|
if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) { |
| 6007 |
|
self::checkForSupport(); |
| 6008 |
|
} |
| 6009 |
|
|
| 6010 |
|
if ( |
| 6011 |
|
self::$SUPPORT['intl'] === true |
| 6012 |
|
&& |
| 6013 |
|
Bootup::is_php('5.4') === true |
| 6014 |
|
) { |
| 6015 |
|
|
| 6016 |
|
$langCode = $lang . '-Upper'; |
| 6017 |
|
if (!in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) { |
| 6018 |
|
$langCode = 'Any-Upper'; |
| 6019 |
|
} |
| 6020 |
|
|
| 6021 |
|
return transliterator_transliterate($langCode, $str); |
| 6022 |
|
} |
| 6023 |
|
|
| 6024 |
|
trigger_error('UTF8::strtoupper() without intl + PHP >= 5.4 cannot handle the "strict"-parameter', E_USER_WARNING); |
| 6025 |
|
} |
| 6026 |
|
|
| 6027 |
|
return \mb_strtoupper($str, $encoding); |
| 6028 |
|
} |
| 6029 |
|
|
| 6030 |
|
/** |
| 6031 |
|
* Translate characters or replace sub-strings. |