Fix SubString{UTF8}

* case which led to endof < 0
* out-of-bounds case
Fix replace for UTF8 strings