Skip to content

@lang:bytes.slice

Extract a byte range from a bytes value.

Returns: bytes

@lang:bytes.slice(value start end?)
NameTypeDescription
valuebytesSource bytes or string value
startnumberStart index (inclusive; negative counts from the end)
[end]numberEnd index (exclusive; negative counts from the end; omitted = to the end)

Both modes use an inclusive start and exclusive end, measured in bytes. Negative indexes count from the end. Bounds clamp to the byte length; reversed ranges return empty bytes. Runtime source and indexes are resolved at execution time. Arbitrary byte ranges are preserved without UTF-8 decoding.