fix inconsistent response from twig_slice

twig_slice can return a boolean when slicing a string outside of its bounds and mbstring is not available.  this would cause a knock-on error in twig_first/twig_last when calling current()

this (as suggested) adds a cast to emulate the behaviour of mb_substr for substr.