Get text between absolute positions

given a state and absolute startPos and endPos how do I get the text in this range (if there is one ?)

That is how do I transfom these position into something I can feed to textBetween ?

Thx!

You can just feed them directly.