Byte sequence | |
Accesses a byte at a given index. | |
Produces a bytes sub-sequence from an existing bytes value. | |
Concatenates two bytes values into one. | |
Comparison operators | |
Returns the number of bytes. | |
Checks if the byte sequence contains a given subsequence. | |
Finds the index of the first occurrence of a subsequence. | |
Converts a str value to bytes using UTF-8 encoding. | |
Returns the string representation of the input value. | |
Returns the specified bit of the bytes value. | |
Returns a Base64-encoded str of the bytes value. | |
Returns the bytes of a Base64-encoded str. |
A sequence of bytes representing raw data.
Bytes can be represented as a literal using this syntax: b''
.
db>
select b'Hello, world';
{b'Hello, world'}
db>
select b'Hello,\x20world\x01';
{b'Hello, world\x01'}
There are also some generic functions that can operate on bytes:
db>
select contains(b'qwerty', b'42');
{false}
Bytes are rendered as base64-encoded strings in JSON. When you cast a
bytes
value into JSON, that’s what you’ll get. In order to
cast
a json
value into bytes, it must be a
base64-encoded string.
db>
select <json>b'Hello EdgeDB!';
{"\"SGVsbG8gRWRnZURCIQ==\""}
db>
select <bytes>to_json("\"SGVsbG8gRWRnZURCIQ==\"");
{b'Hello EdgeDB!'}
Returns the specified bit of the bytes
value.
When looking for the nth bit, this function will enumerate bits from least to most significant in each byte.
db> ... ...
for n in {0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13 ,14, 15}
union bytes_get_bit(b'ab', n);
{1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0}