| @@ 129-147 (lines=19) @@ | ||
| 126 | * @param string $strEncoding Encoding of text |
|
| 127 | * @return string |
|
| 128 | */ |
|
| 129 | public static function lowerCase($strText, $strEncoding = '') |
|
| 130 | { |
|
| 131 | ||
| 132 | if (is_null(self::$blnMbstring)) { |
|
| 133 | self::$blnMbstring = extension_loaded('mbstring'); |
|
| 134 | } |
|
| 135 | ||
| 136 | if (!self::$blnMbstring) { |
|
| 137 | $strLowerCaseText = strtolower($strText); |
|
| 138 | } else { |
|
| 139 | if ($strEncoding == '') { |
|
| 140 | $strLowerCaseText = mb_strtolower($strText); |
|
| 141 | } else { |
|
| 142 | $strLowerCaseText = mb_strtolower($strText, $strEncoding); |
|
| 143 | } |
|
| 144 | } |
|
| 145 | ||
| 146 | return $strLowerCaseText; |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * Converts string to upper case. Tries mb_strtoupper and if that fails uses regular strtoupper. |
|
| @@ 155-173 (lines=19) @@ | ||
| 152 | * @param string $strEncoding Encoding of text |
|
| 153 | * @return string |
|
| 154 | */ |
|
| 155 | public static function upperCase($strText, $strEncoding = '') |
|
| 156 | { |
|
| 157 | ||
| 158 | if (is_null(self::$blnMbstring)) { |
|
| 159 | self::$blnMbstring = extension_loaded('mbstring'); |
|
| 160 | } |
|
| 161 | ||
| 162 | if (!self::$blnMbstring) { |
|
| 163 | $strUpperCaseText = strtoupper($strText); |
|
| 164 | } else { |
|
| 165 | if ($strEncoding == '') { |
|
| 166 | $strUpperCaseText = mb_strtoupper($strText); |
|
| 167 | } else { |
|
| 168 | $strUpperCaseText = mb_strtoupper($strText, $strEncoding); |
|
| 169 | } |
|
| 170 | } |
|
| 171 | ||
| 172 | return $strUpperCaseText; |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * Gets portion of string. Tries mb_substr and if that fails uses regular substr. |
|
| @@ 209-227 (lines=19) @@ | ||
| 206 | * @param string $strEncoding Encoding of text |
|
| 207 | * @return int |
|
| 208 | */ |
|
| 209 | public static function textLength($strText, $strEncoding = '') |
|
| 210 | { |
|
| 211 | ||
| 212 | if (is_null(self::$blnMbstring)) { |
|
| 213 | self::$blnMbstring = extension_loaded('mbstring'); |
|
| 214 | } |
|
| 215 | ||
| 216 | if (!self::$blnMbstring) { |
|
| 217 | $intTextLength = strlen($strText); |
|
| 218 | } else { |
|
| 219 | if ($strEncoding == '') { |
|
| 220 | $intTextLength = mb_strlen($strText); |
|
| 221 | } else { |
|
| 222 | $intTextLength = mb_strlen($strText, $strEncoding); |
|
| 223 | } |
|
| 224 | } |
|
| 225 | ||
| 226 | return $intTextLength; |
|
| 227 | } |
|
| 228 | ||
| 229 | /** |
|
| 230 | * Alias for textLength, as "letterCount", "wordCount" etc also used |
|