package spotlib

  1. Overview
  2. Docs
include module type of struct include Stdlib.Bytes end
val length : bytes -> int
val get : bytes -> int -> char
val set : bytes -> int -> char -> unit
val create : int -> bytes
val make : int -> char -> bytes
val init : int -> (int -> char) -> bytes
val empty : bytes
val copy : bytes -> bytes
val of_string : string -> bytes
val to_string : bytes -> string
val sub : bytes -> int -> int -> bytes
val sub_string : bytes -> int -> int -> string
val extend : bytes -> int -> int -> bytes
val fill : bytes -> int -> int -> char -> unit
val blit : bytes -> int -> bytes -> int -> int -> unit
val blit_string : string -> int -> bytes -> int -> int -> unit
val concat : bytes -> bytes list -> bytes
val cat : bytes -> bytes -> bytes
val iter : (char -> unit) -> bytes -> unit
val iteri : (int -> char -> unit) -> bytes -> unit
val map : (char -> char) -> bytes -> bytes
val mapi : (int -> char -> char) -> bytes -> bytes
val fold_left : ('a -> char -> 'a) -> 'a -> bytes -> 'a
val fold_right : (char -> 'a -> 'a) -> bytes -> 'a -> 'a
val for_all : (char -> bool) -> bytes -> bool
val exists : (char -> bool) -> bytes -> bool
val trim : bytes -> bytes
val escaped : bytes -> bytes
val index : bytes -> char -> int
val rindex : bytes -> char -> int
val rindex_opt : bytes -> char -> int option
val index_from : bytes -> int -> char -> int
val index_from_opt : bytes -> int -> char -> int option
val rindex_from : bytes -> int -> char -> int
val rindex_from_opt : bytes -> int -> char -> int option
val contains : bytes -> char -> bool
val contains_from : bytes -> int -> char -> bool
val rcontains_from : bytes -> int -> char -> bool
val uppercase : bytes -> bytes
  • deprecated Use Bytes.uppercase_ascii/BytesLabels.uppercase_ascii instead.
val lowercase : bytes -> bytes
  • deprecated Use Bytes.lowercase_ascii/BytesLabels.lowercase_ascii instead.
val capitalize : bytes -> bytes
  • deprecated Use Bytes.capitalize_ascii/BytesLabels.capitalize_ascii instead.
val uncapitalize : bytes -> bytes
  • deprecated Use Bytes.uncapitalize_ascii/BytesLabels.uncapitalize_ascii instead.
val uppercase_ascii : bytes -> bytes
val lowercase_ascii : bytes -> bytes
val capitalize_ascii : bytes -> bytes
val uncapitalize_ascii : bytes -> bytes
type t = bytes
val compare : t -> t -> int
val equal : t -> t -> bool
val starts_with : prefix:bytes -> bytes -> bool
val ends_with : suffix:bytes -> bytes -> bool
val unsafe_to_string : bytes -> string
val unsafe_of_string : string -> bytes
val split_on_char : char -> bytes -> bytes list
val to_seq : t -> char Stdlib.Seq.t
val to_seqi : t -> (int * char) Stdlib.Seq.t
val of_seq : char Stdlib.Seq.t -> t
val get_utf_8_uchar : t -> int -> Stdlib.Uchar.utf_decode
val set_utf_8_uchar : t -> int -> Stdlib.Uchar.t -> int
val is_valid_utf_8 : t -> bool
val get_utf_16be_uchar : t -> int -> Stdlib.Uchar.utf_decode
val set_utf_16be_uchar : t -> int -> Stdlib.Uchar.t -> int
val is_valid_utf_16be : t -> bool
val get_utf_16le_uchar : t -> int -> Stdlib.Uchar.utf_decode
val set_utf_16le_uchar : t -> int -> Stdlib.Uchar.t -> int
val is_valid_utf_16le : t -> bool
val get_uint8 : bytes -> int -> int
val get_int8 : bytes -> int -> int
val get_uint16_ne : bytes -> int -> int
val get_uint16_be : bytes -> int -> int
val get_uint16_le : bytes -> int -> int
val get_int16_ne : bytes -> int -> int
val get_int16_be : bytes -> int -> int
val get_int16_le : bytes -> int -> int
val get_int32_ne : bytes -> int -> int32
val get_int32_be : bytes -> int -> int32
val get_int32_le : bytes -> int -> int32
val get_int64_ne : bytes -> int -> int64
val get_int64_be : bytes -> int -> int64
val get_int64_le : bytes -> int -> int64
val set_uint8 : bytes -> int -> int -> unit
val set_int8 : bytes -> int -> int -> unit
val set_uint16_ne : bytes -> int -> int -> unit
val set_uint16_be : bytes -> int -> int -> unit
val set_uint16_le : bytes -> int -> int -> unit
val set_int16_ne : bytes -> int -> int -> unit
val set_int16_be : bytes -> int -> int -> unit
val set_int16_le : bytes -> int -> int -> unit
val set_int32_ne : bytes -> int -> int32 -> unit
val set_int32_be : bytes -> int -> int32 -> unit
val set_int32_le : bytes -> int -> int32 -> unit
val set_int64_ne : bytes -> int -> int64 -> unit
val set_int64_be : bytes -> int -> int64 -> unit
val set_int64_le : bytes -> int -> int64 -> unit
val unsafe_get : bytes -> int -> char
val unsafe_set : bytes -> int -> char -> unit
val unsafe_blit : bytes -> int -> bytes -> int -> int -> unit
val unsafe_blit_string : string -> int -> bytes -> int -> int -> unit
val unsafe_fill : bytes -> int -> int -> char -> unit
include module type of struct include Xbytes end

Construction

val make1 : char -> bytes

make1 = Bytes.make 1

val of_char : char -> bytes

Sysnonym make1

Deconstruction

val to_array : bytes -> char array
val to_code_array : bytes -> int array

Array

val get_opt : bytes -> int -> char option
val scani_left : (int -> 'a -> char -> [< `Continue of 'a | `Stop of 'a ]) -> 'a -> ?from:int -> ?to_:int -> bytes -> 'a
val foldi_left : (int -> 'a -> char -> [< `Continue of 'a | `Stop of 'a ]) -> 'a -> bytes -> 'a
val replace_chars : char -> char -> bytes -> bytes

replace_chars c1 c2 s returns a copy of s with replacing all the char occurrences of c1 by c2.

Transform

val chop_eols : bytes -> bytes

chop_eols s returns the bytes s w/o the end-of-line chars. chop from Perl. chop_eols "hello\r\n" = "hello" chop_eols "hello\n" = "hello" chop_eols "hello\r" = "hello" chop_eols "hello" = "hello"

Sub

val sub_from_to : bytes -> int -> int -> bytes
val sub' : bytes -> int -> int -> bytes

Same as Bytes.sub but even if the bytes shorter for len the function succeeds and returns a shorter subbytes.

val is_sub : ?from:int -> needle:bytes -> bytes -> bool
val is_prefix : ?from:int -> bytes -> bytes -> bool
val is_postfix : bytes -> bytes -> bool
val is_prefix' : ?from:int -> bytes -> bytes -> bytes option

Same as prefix but returns the postfix

val is_postfix' : bytes -> bytes -> bytes option

Same as postfix but returns the prefix

val index_from_to : bytes -> int -> int -> char -> int option
val index_bytes_from : bytes -> int -> bytes -> int
val split_at : int -> bytes -> bytes * bytes

Haskelish bytes sub

val take : int -> bytes -> bytes
val drop : int -> bytes -> bytes
val drop_postfix : int -> bytes -> bytes
val prefix : int -> bytes -> bytes

same as take

val postfix : int -> bytes -> bytes

Split

val lines : bytes -> (bytes * bytes) list

lines "hello\nworld\r\ngood\rday" = ["hello", "\n"; "world", "\r\n"; "good", "\r"; "day", ""]

val split : (char -> bool) -> bytes -> bytes list

split (function ' ' -> true | _ -> false) "hello world" = ["hello"; "world"]

val split1 : ?from:int -> (char -> bool) -> bytes -> (bytes * bytes) option

Same as split but do the split only once

val words : bytes -> bytes list

Split a bytes into "words" by white characters ' ', '\t', '\r' and '\n'

val index_opt : bytes -> char -> int option

Optionalized

val find : bytes -> int -> (char -> bool) -> int option

Random

val random : int -> bytes
val random_hum : int -> bytes

human readable

Misc

val is_space_or_tab : char -> bool
val is_newline_or_return : char -> bool

Stdlib

module Stdlib = Xbytes.Stdlib

Set

module Set = Xbytes.Set
OCaml

Innovation. Community. Security.