
Joseph
Muchas gracias, Eloy,
However, it only works with the first syntax. If I want to return the first 30 characters of string $mystring:
$return = $textlib->substr($mystring, 0, 30);
works ok
$return = moodle_substr($mystring, 0, 30);
does not work.
Joseph
PS.- In the meantime I had used this small function, which works welll:
function utf8_substr($str, $from, $len){
return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s','$1',$str);
}