15 static public function subStr($a_str, $a_start, $a_length = NULL)
17 if (function_exists(
"mb_substr"))
20 if ($a_length === NULL)
24 return mb_substr($a_str, $a_start, $a_length,
"UTF-8");
28 return substr($a_str, $a_start, $a_length);
32 static function strPos($a_haystack, $a_needle, $a_offset = NULL)
34 if (function_exists(
"mb_strpos"))
36 return mb_strpos($a_haystack, $a_needle, $a_offset,
"UTF-8");
40 return strpos($a_haystack, $a_needle, $a_offset);
44 static function strIPos($a_haystack, $a_needle, $a_offset = NULL)
46 if (function_exists(
"mb_stripos"))
48 return mb_stripos($a_haystack, $a_needle, $a_offset,
"UTF-8");
52 return stripos($a_haystack, $a_needle, $a_offset);
77 static public function strLen($a_string)
79 if (function_exists(
"mb_strlen"))
81 return mb_strlen($a_string,
"UTF-8");
85 return strlen($a_string);
91 if (function_exists(
"mb_strtolower"))
93 return mb_strtolower($a_string,
"UTF-8");
97 return strtolower($a_string);
103 $a_string = (string) $a_string;
104 if (function_exists(
"mb_strtoupper"))
106 return mb_strtoupper($a_string,
"UTF-8");
110 return strtoupper($a_string);
121 if (is_object($ilCollator))
144 static public function shortenText($a_string,$a_start_pos,$a_num_bytes,$a_encoding =
'UTF-8')
146 return mb_strcut($a_string, $a_start_pos, $a_num_bytes, $a_encoding);
154 if (function_exists(
"mb_detect_encoding"))
156 if (mb_detect_encoding($a_str,
"UTF-8") ==
"UTF-8")
167 for($i=0; $i<$len; $i++){
170 if(($c >= 254))
return false;
171 elseif($c >= 252) $bits=6;
172 elseif($c >= 248) $bits=5;
173 elseif($c >= 240) $bits=4;
174 elseif($c >= 224) $bits=3;
175 elseif($c >= 192) $bits=2;
177 if(($i+$bits) > $len)
return false;
181 if($b < 128 || $b > 191)
return false;
199 static public function strPosAll($a_haystack, $a_needle)
201 $positions = array();
203 while(is_int($pos = strpos($a_haystack, $a_needle, $cpos)))
216 if (is_int(strpos($a_str, $a_old)))
218 $a_str = substr_replace ($a_str, $a_new, strpos($a_str, $a_old), strlen($a_old));