VTSafeSubstring function.