Byte Operators¶
TEAL byte slices are similar to strings and can be manipulated in the same way.
Length¶
The length of a byte slice can be obtained using the Len
expression. For example:
Len(Bytes("")) # will produce 0
Len(Bytes("algorand")) # will produce 8
Concatenation¶
Byte slices can be combined using the Concat
expression. This expression takes at least
two arguments and produces a new byte slice consisting of each argument, one after another. For
example:
Concat(Bytes("a"), Bytes("b"), Bytes("c")) # will produce "abc"
Substring Extraction¶
Byte slices can be extracted from other byte slices using the Substring
and Extract
expressions. These expressions are extremely similar, except one specifies a substring by start and
end indexes, while the other uses a start index and length. Use whichever makes sense for your
application.
Manipulating Individual Bits and Bytes¶
The individual bits and bytes in a byte string can be extracted and changed. See Bit and Byte Operations for more information.