32 $args = func_get_args();
33 $str =& array_shift($args);
34 if (!is_string($str))
return false;
46 $c = strlen(utf8_decode(substr($str,0,$i)));
51 foreach ($args as $offset) {
55 if ($offset == 0) { $result[] = 0;
continue; }
62 if ( ($c - $prev[1]) == 0 ) {
69 $j = $i + (int)(($offset-$c) * ($i - $prev[0]) / ($c - $prev[1]));
79 $c += strlen(utf8_decode(substr($str,$i,$j-$i)));
82 $c -= strlen(utf8_decode(substr($str,$j,$i-$j)));
85 $error = abs($c-$offset);
91 }
while ( ($error > 7) && --$safety_valve) ;
93 if ($error && $error <= 7) {
109 if ( count($result) == 1 ) {
133 if ($idx <= 0)
return 0;
135 $limit = strlen($str);
136 if ($idx >= $limit)
return $limit;
141 while ($idx && ((ord($str[$idx]) & 0xC0) == 0x80)) $idx--;
161 if ($idx <= 0)
return 0;
163 $limit = strlen($str);
164 if ($idx >= $limit)
return $limit;
169 while (($idx < $limit) && ((ord($str[$idx]) & 0xC0) == 0x80)) $idx++;