// this works even where the string contains surrogate pairs,
// because the Java length is always >= the XPath length
lend = slength+1;
} else {
try {
lend = end.ceiling().longValue();
} catch (XPathException err) {
// this shouldn't happen unless the string length exceeds the bounds
// of a long
throw new AssertionError("string length out of permissible range");
}