Modifying A String With blit_string
ReasonML's Bytes
module has a function called blit_string
. This function allows you to copy portions of a string into a destination byte sequence. It is a fairly low-level operation, so you have to provide a source string and provide an offset of that source string to start copying from. You then have to provide a properly sized byte sequence as well as the destination's starting offset and length of bytes to be copied.
Here is an example of how we can use blit_string
to create a copy of the string with the first character removed.
Notice that once the byte sequence has been copied over, we then need to convert it back into a string.
Last updated