faster isvalid(SubString,i)

Replaces the closed pull request #7744, which specialized isvalid on SubString{UTF8String}.

This version, based on @ivarne 's proposed alternative is more general, covering all SubStrings.
It runs faster on Linux, and much faster on Windows, because it avoids use of try/except in most cases.