How to recover substrings from text in a post given UTF-8 indices? #3019
Unanswered
r002
asked this question in
How to do it?
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I'm new here, so apologies if this is a newbie question! I've been playing w/ the bsky APIs and ATProto for the past month and am currently trying to parse a hydrated post.
I have this:
but just need an easy way to map the
did
to thehandle
. I did read the docs and see here we're not supposed to use.slice()
bc JS isutf-16
vs ATProto'sutf-8
.So what is the best way to do this today? Basically, I just want a richText library function where I can put in the text and indices and get back the substring I'm interested in. Something like,
.getText(text, 113, 134)
and get backmmasnick.bsky.social
. Do I just write my own? Is there already an existing helper function in theATProto RichText
library that I'm unaware of?If someone could pls advise, I'd be grateful. TIA!! 🙏
Beta Was this translation helpful? Give feedback.
All reactions