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 introduces a new function twig_substr to emulate the behaviour of mb_substr for substr.
should be on one line