How can I get nth byte of ByteString in Haskell?
I tried to find function like !! for ByteStrings, but found nothing.
How can I get nth byte of ByteString in Haskell?
I tried to find function like !! for ByteStrings, but found nothing.
Copyright © 2021 Jogjafile Inc.
ByteString.index is the function you're looking for.
Most of the "containerish" types emulate the extended list interface; you also want to be careful because that
indexfunction will crash the program if you feed it a string that's too short (as will!!on ordinary lists). A better implementation might bewhich, reading inside out, drops the first n bytes (maybe producing an empty byte string), then attempts to split the first character from the remainder, and if successful, ignores the rest of the string.