|
@@ 6181-6225 (lines=45) @@
|
| 6178 |
|
* |
| 6179 |
|
* @return string str with all alphabetic characters converted to lowercase. |
| 6180 |
|
*/ |
| 6181 |
|
public static function strtolower($str, $encoding = 'UTF-8', $cleanUtf8 = false, $lang = null) |
| 6182 |
|
{ |
| 6183 |
|
// init |
| 6184 |
|
$str = (string)$str; |
| 6185 |
|
|
| 6186 |
|
if (!isset($str[0])) { |
| 6187 |
|
return ''; |
| 6188 |
|
} |
| 6189 |
|
|
| 6190 |
|
if ($cleanUtf8 === true) { |
| 6191 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 6192 |
|
// if invalid characters are found in $haystack before $needle |
| 6193 |
|
$str = self::clean($str); |
| 6194 |
|
} |
| 6195 |
|
|
| 6196 |
|
if ($encoding !== 'UTF-8') { |
| 6197 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 6198 |
|
} |
| 6199 |
|
|
| 6200 |
|
if ($lang !== null) { |
| 6201 |
|
if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) { |
| 6202 |
|
self::checkForSupport(); |
| 6203 |
|
} |
| 6204 |
|
|
| 6205 |
|
if ( |
| 6206 |
|
self::$SUPPORT['intl'] === true |
| 6207 |
|
&& |
| 6208 |
|
Bootup::is_php('5.4') === true |
| 6209 |
|
) { |
| 6210 |
|
|
| 6211 |
|
$langCode = $lang . '-Lower'; |
| 6212 |
|
if (!in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) { |
| 6213 |
|
trigger_error('UTF8::strtolower() without intl for special language: ' . $lang, E_USER_WARNING); |
| 6214 |
|
|
| 6215 |
|
$langCode = 'Any-Lower'; |
| 6216 |
|
} |
| 6217 |
|
|
| 6218 |
|
return transliterator_transliterate($langCode, $str); |
| 6219 |
|
} |
| 6220 |
|
|
| 6221 |
|
trigger_error('UTF8::strtolower() without intl + PHP >= 5.4 cannot handle the "lang"-parameter: ' . $lang, E_USER_WARNING); |
| 6222 |
|
} |
| 6223 |
|
|
| 6224 |
|
return \mb_strtolower($str, $encoding); |
| 6225 |
|
} |
| 6226 |
|
|
| 6227 |
|
/** |
| 6228 |
|
* Generic case sensitive transformation for collation matching. |
|
@@ 6252-6295 (lines=44) @@
|
| 6249 |
|
* |
| 6250 |
|
* @return string str with all alphabetic characters converted to uppercase. |
| 6251 |
|
*/ |
| 6252 |
|
public static function strtoupper($str, $encoding = 'UTF-8', $cleanUtf8 = false, $lang = null) |
| 6253 |
|
{ |
| 6254 |
|
$str = (string)$str; |
| 6255 |
|
|
| 6256 |
|
if (!isset($str[0])) { |
| 6257 |
|
return ''; |
| 6258 |
|
} |
| 6259 |
|
|
| 6260 |
|
if ($cleanUtf8 === true) { |
| 6261 |
|
// "\mb_strpos" and "\iconv_strpos" returns wrong position, |
| 6262 |
|
// if invalid characters are found in $haystack before $needle |
| 6263 |
|
$str = self::clean($str); |
| 6264 |
|
} |
| 6265 |
|
|
| 6266 |
|
if ($encoding !== 'UTF-8') { |
| 6267 |
|
$encoding = self::normalize_encoding($encoding, 'UTF-8'); |
| 6268 |
|
} |
| 6269 |
|
|
| 6270 |
|
if ($lang !== null) { |
| 6271 |
|
if (!isset(self::$SUPPORT['already_checked_via_portable_utf8'])) { |
| 6272 |
|
self::checkForSupport(); |
| 6273 |
|
} |
| 6274 |
|
|
| 6275 |
|
if ( |
| 6276 |
|
self::$SUPPORT['intl'] === true |
| 6277 |
|
&& |
| 6278 |
|
Bootup::is_php('5.4') === true |
| 6279 |
|
) { |
| 6280 |
|
|
| 6281 |
|
$langCode = $lang . '-Upper'; |
| 6282 |
|
if (!in_array($langCode, self::$SUPPORT['intl__transliterator_list_ids'], true)) { |
| 6283 |
|
trigger_error('UTF8::strtoupper() without intl for special language: ' . $lang, E_USER_WARNING); |
| 6284 |
|
|
| 6285 |
|
$langCode = 'Any-Upper'; |
| 6286 |
|
} |
| 6287 |
|
|
| 6288 |
|
return transliterator_transliterate($langCode, $str); |
| 6289 |
|
} |
| 6290 |
|
|
| 6291 |
|
trigger_error('UTF8::strtolower() without intl + PHP >= 5.4 cannot handle the "lang"-parameter: ' . $lang, E_USER_WARNING); |
| 6292 |
|
} |
| 6293 |
|
|
| 6294 |
|
return \mb_strtoupper($str, $encoding); |
| 6295 |
|
} |
| 6296 |
|
|
| 6297 |
|
/** |
| 6298 |
|
* Translate characters or replace sub-strings. |