TextStoreage Range acts weird when there's fractions in the text?

I have a script to replace selected glyphs with a kerning context for each glyph, the script is supposed to replace all the text in the tab. It works for everything except fractions, the behaviour is strange when there’s fraction, it’s like it doesn’t get the full range of text.

I made a simplified version here:

Result if I selected
abc

in a tab that only had abc and ran it:

abc
ddabonn
ddbbonn
ddcbonn

Result if I selected
/zero.numr/one.numr/two.numr/three.numr/four.numr/five.numr/six.numr/seven.numr/eight.numr/nine.numr
in a tab that only contained this text:

/zero.numr/one.numr/two.numr/three.numr/four.numr/five.numr/six.numr/seven.numr/eight.numr/nine.numr
dd/zero.numr bonn
dd/one.numr bonn
dd/two.numr bonn
dd/three.numr bonn
dd/four.numr bonn
dd/five.numr bonn
dd/six.numr bonn
dd/seven.numr bonn
dd/eight.numr bonn
dd/nine.numr bonn
/five.numr/six.numr/seven.numr/eight.numr/nine.numr

It keeps the last 5 strings from the selected string for some reason?

Another strange input:
ł/l.ss01 turns into

ł/l.ss01
ddłbonn
dd/l.ss01 bonn
/.notdef

Screen Shot 2023-06-06 at 4.28.29 pm

If you access the text, you need to escape the unencoded glyphs with slashes. Until the following space or slash, it is the glyph name.

But if you aim to replace the complete text anyway, why not simply set tab.text="abc"?

That’s a good solution, thank you