Procedures for manipulation of `[]byte` slices.

Collection Info

View Source
Collection
core
Path
bytes
Entries
128

Source Files

Constants

1

Types

2

Buffer #

Source
Buffer :: Buffer

A Buffer is a variable-sized buffer of bytes with a io.Stream interface The zero value for Buffer is an empty buffer ready to use.

Procedures

125

alias #

Source
alias :: proc "contextless" (a, b: []u8) -> bool {…}

alias returns true if and only if (⟺) a and b have a non-zero length, and any part of a overlaps with b.

alias_inexactly #

Source
alias_inexactly :: proc "contextless" (a, b: []u8) -> bool {…}

alias_inexactly returns true if and only if (⟺) a and b have a non-zero length, the base pointer of a and b are NOT equal, and any part of a overlaps with b (ie: `alias(a, b)` with an exception that returns false for `a == b`, `b = a[:len(a)-69]` and similar conditions).

buffer_init_allocator #

Source
buffer_init_allocator :: proc(b: ^Buffer, len, cap: int, allocator := context.allocator, loc := #caller_location) {…}

center_justify #

Source
center_justify :: proc(str: []u8, length: int, pad: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

centre_justify returns a byte slice with a pad byte slice at boths sides if the str's rune length is smaller than length

centre_justify #

Source
centre_justify :: proc(str: []u8, length: int, pad: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

centre_justify returns a byte slice with a pad byte slice at boths sides if the str's rune length is smaller than length

clone #

Source
clone :: proc(s: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

compare #

Source
compare :: proc(lhs, rhs: []u8) -> int {…}

Compares two []byte, returning a value representing which one comes first lexiographically. Returns: -1 for `lhs`, 1 for `rhs`, or 0 if they are equal.

concatenate #

Source
concatenate :: proc(a: [][]u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

expand_tabs #

Source
expand_tabs :: proc(s: []u8, tab_size: int, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

fields #

Source
fields :: proc(s: []u8, allocator := context.allocator, loc := #caller_location) -> [][]u8 {…}

fields splits the byte slice s around each instance of one or more consecutive white space character, defined by unicode.is_space returning a slice of subslices of s or an empty slice if s only contains white space

fields_proc #

Source
fields_proc :: proc(s: []u8, f: proc(rune) -> bool, allocator := context.allocator, loc := #caller_location) -> [][]u8 {…}

fields_proc splits the byte slice s at each run of unicode code points `ch` satisfying f(ch) returns a slice of subslices of s If all code points in s satisfy f(ch) or string is empty, an empty slice is returned fields_proc makes no guarantee about the order in which it calls f(ch) it assumes that `f` always returns the same value for a given ch

index_byte #

Source
index_byte :: proc "contextless" (s: []u8, c: u8) -> (index: int) {…}

Scan a slice of bytes for a specific byte. This procedure safely handles slices of any length, including empty slices. Inputs: - data: A slice of bytes. - c: The byte to search for. Returns: - index: The index of the byte `c`, or -1 if it was not found.

join #

Source
join :: proc(a: [][]u8, sep: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

last_index_byte #

Source
last_index_byte :: proc "contextless" (s: []u8, c: u8) -> int {…}

Scan a slice of bytes for a specific byte, starting from the end and working backwards to the start. This procedure safely handles slices of any length, including empty slices. Inputs: - data: A slice of bytes. - c: The byte to search for. Returns: - index: The index of the byte `c`, or -1 if it was not found.

left_justify #

Source
left_justify :: proc(str: []u8, length: int, pad: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

left_justify returns a byte slice with a pad byte slice at left side if the str's rune length is smaller than length

remove #

Source
remove :: proc(s, key: []u8, n: int, allocator := context.allocator, loc := #caller_location) -> (output: []u8, was_allocation: bool) {…}

remove_all #

Source
remove_all :: proc(s, key: []u8, allocator := context.allocator, loc := #caller_location) -> (output: []u8, was_allocation: bool) {…}

repeat #

Source
repeat :: proc(s: []u8, count: int, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

replace #

Source
replace :: proc(
	s, old, new: []u8, 
	n:           int, 
	allocator := context.allocator, 
	loc := #caller_location, 
) -> (output: []u8, was_allocation: bool) {…}

if n < 0, no limit on the number of replacements

replace_all #

Source
replace_all :: proc(s, old, new: []u8, allocator := context.allocator, loc := #caller_location) -> (output: []u8, was_allocation: bool) {…}

reverse #

Source
reverse :: proc(s: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

right_justify #

Source
right_justify :: proc(str: []u8, length: int, pad: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

right_justify returns a byte slice with a pad byte slice at right side if the str's rune length is smaller than length

scrub #

Source
scrub :: proc(s: []u8, replacement: []u8, allocator := context.allocator, loc := #caller_location) -> []u8 {…}

Scrubs invalid utf-8 characters and replaces them with the replacement string Adjacent invalid bytes are only replaced once

split #

Source
split :: proc(s, sep: []u8, allocator := context.allocator, loc := #caller_location) -> [][]u8 {…}

split_after #

Source
split_after :: proc(s, sep: []u8, allocator := context.allocator, loc := #caller_location) -> [][]u8 {…}

split_after_n #

Source
split_after_n :: proc(s, sep: []u8, n: int, allocator := context.allocator, loc := #caller_location) -> [][]u8 {…}

split_multi #

Source
split_multi :: proc(s: []u8, substrs: [][]u8, skip_empty: bool = false, allocator := context.allocator, loc := #caller_location) -> [][]u8 {…}

split_n #

Source
split_n :: proc(s, sep: []u8, n: int, allocator := context.allocator, loc := #caller_location) -> [][]u8 {…}