no, because then, the offsets would be wrong... maybe you could use the
utf8::upgrade function to mark the returned strings as unicode but your code would become really ugly and unmaintainable.
If you are looking for common file paths why don't you use something simpler like:
sub diffpath_ix {
my ($a, $b) = @_;
my $last = 0;
while ( $a=~m{(\G[^/]*/)}g ) {
if ( substr($b, $last, length $1) eq $1 ) {
$last = pos $a
}
else {
return $last
}
}
if (substr($a, $last) eq substr($b, $last)) {
return length $a
}
return $last;
}