.TH "StdLabels.Bytes" 3o source: 2019-01-25 OCamldoc "OCaml library" .SH NAME StdLabels.Bytes \- no description .SH Module Module StdLabels.Bytes .SH Documentation .sp Module .BI "Bytes" : .B (module BytesLabels) .sp .sp .sp .sp .I val length : .B bytes -> int .sp Return the length (number of bytes) of the argument\&. .sp .I val get : .B bytes -> int -> char .sp .B get s n returns the byte at index .B n in argument .B s \&. .sp Raise .B Invalid_argument if .B n is not a valid index in .B s \&. .sp .I val set : .B bytes -> int -> char -> unit .sp .B set s n c modifies .B s in place, replacing the byte at index .B n with .B c \&. .sp Raise .B Invalid_argument if .B n is not a valid index in .B s \&. .sp .I val create : .B int -> bytes .sp .B create n returns a new byte sequence of length .B n \&. The sequence is uninitialized and contains arbitrary bytes\&. .sp Raise .B Invalid_argument if .B n < 0 or .B n > .B Sys\&.max_string_length \&. .sp .I val make : .B int -> char -> bytes .sp .B make n c returns a new byte sequence of length .B n , filled with the byte .B c \&. .sp Raise .B Invalid_argument if .B n < 0 or .B n > .B Sys\&.max_string_length \&. .sp .I val init : .B int -> f:(int -> char) -> bytes .sp .B init n f returns a fresh byte sequence of length .B n , with character .B i initialized to the result of .B f i \&. .sp Raise .B Invalid_argument if .B n < 0 or .B n > .B Sys\&.max_string_length \&. .sp .I val empty : .B bytes .sp A byte sequence of size 0\&. .sp .I val copy : .B bytes -> bytes .sp Return a new byte sequence that contains the same bytes as the argument\&. .sp .I val of_string : .B string -> bytes .sp Return a new byte sequence that contains the same bytes as the given string\&. .sp .I val to_string : .B bytes -> string .sp Return a new string that contains the same bytes as the given byte sequence\&. .sp .I val sub : .B bytes -> pos:int -> len:int -> bytes .sp .B sub s start len returns a new byte sequence of length .B len , containing the subsequence of .B s that starts at position .B start and has length .B len \&. .sp Raise .B Invalid_argument if .B start and .B len do not designate a valid range of .B s \&. .sp .I val sub_string : .B bytes -> int -> int -> string .sp Same as .B sub but return a string instead of a byte sequence\&. .sp .I val extend : .B bytes -> left:int -> right:int -> bytes .sp .B extend s left right returns a new byte sequence that contains the bytes of .B s , with .B left uninitialized bytes prepended and .B right uninitialized bytes appended to it\&. If .B left or .B right is negative, then bytes are removed (instead of appended) from the corresponding side of .B s \&. .sp Raise .B Invalid_argument if the result length is negative or longer than .B Sys\&.max_string_length bytes\&. .sp .B "Since" 4.05.0 .sp .I val fill : .B bytes -> pos:int -> len:int -> char -> unit .sp .B fill s start len c modifies .B s in place, replacing .B len characters with .B c , starting at .B start \&. .sp Raise .B Invalid_argument if .B start and .B len do not designate a valid range of .B s \&. .sp .I val blit : .B src:bytes -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit .sp .B blit src srcoff dst dstoff len copies .B len bytes from sequence .B src , starting at index .B srcoff , to sequence .B dst , starting at index .B dstoff \&. It works correctly even if .B src and .B dst are the same byte sequence, and the source and destination intervals overlap\&. .sp Raise .B Invalid_argument if .B srcoff and .B len do not designate a valid range of .B src , or if .B dstoff and .B len do not designate a valid range of .B dst \&. .sp .I val blit_string : .B src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit .sp .B blit src srcoff dst dstoff len copies .B len bytes from string .B src , starting at index .B srcoff , to byte sequence .B dst , starting at index .B dstoff \&. .sp Raise .B Invalid_argument if .B srcoff and .B len do not designate a valid range of .B src , or if .B dstoff and .B len do not designate a valid range of .B dst \&. .sp .B "Since" 4.05.0 .sp .I val concat : .B sep:bytes -> bytes list -> bytes .sp .B concat sep sl concatenates the list of byte sequences .B sl , inserting the separator byte sequence .B sep between each, and returns the result as a new byte sequence\&. .sp .I val cat : .B bytes -> bytes -> bytes .sp .B cat s1 s2 concatenates .B s1 and .B s2 and returns the result as new byte sequence\&. .sp Raise .B Invalid_argument if the result is longer than .B Sys\&.max_string_length bytes\&. .sp .B "Since" 4.05.0 .sp .I val iter : .B f:(char -> unit) -> bytes -> unit .sp .B iter f s applies function .B f in turn to all the bytes of .B s \&. It is equivalent to .B f (get s 0); f (get s 1); \&.\&.\&.; f (get s .B (length s \- 1)); () \&. .sp .I val iteri : .B f:(int -> char -> unit) -> bytes -> unit .sp Same as .B Bytes\&.iter , but the function is applied to the index of the byte as first argument and the byte itself as second argument\&. .sp .I val map : .B f:(char -> char) -> bytes -> bytes .sp .B map f s applies function .B f in turn to all the bytes of .B s and stores the resulting bytes in a new sequence that is returned as the result\&. .sp .I val mapi : .B f:(int -> char -> char) -> bytes -> bytes .sp .B mapi f s calls .B f with each character of .B s and its index (in increasing index order) and stores the resulting bytes in a new sequence that is returned as the result\&. .sp .I val trim : .B bytes -> bytes .sp Return a copy of the argument, without leading and trailing whitespace\&. The bytes regarded as whitespace are the ASCII characters .B \&' \&' , .B \&'\(rs012\&' , .B \&'\(rsn\&' , .B \&'\(rsr\&' , and .B \&'\(rst\&' \&. .sp .I val escaped : .B bytes -> bytes .sp Return a copy of the argument, with special characters represented by escape sequences, following the lexical conventions of OCaml\&. .sp .I val index : .B bytes -> char -> int .sp .B index s c returns the index of the first occurrence of byte .B c in .B s \&. .sp Raise .B Not_found if .B c does not occur in .B s \&. .sp .I val index_opt : .B bytes -> char -> int option .sp .B index_opt s c returns the index of the first occurrence of byte .B c in .B s or .B None if .B c does not occur in .B s \&. .sp .B "Since" 4.05 .sp .I val rindex : .B bytes -> char -> int .sp .B rindex s c returns the index of the last occurrence of byte .B c in .B s \&. .sp Raise .B Not_found if .B c does not occur in .B s \&. .sp .I val rindex_opt : .B bytes -> char -> int option .sp .B rindex_opt s c returns the index of the last occurrence of byte .B c in .B s or .B None if .B c does not occur in .B s \&. .sp .B "Since" 4.05 .sp .I val index_from : .B bytes -> int -> char -> int .sp .B index_from s i c returns the index of the first occurrence of byte .B c in .B s after position .B i \&. .B Bytes\&.index s c is equivalent to .B Bytes\&.index_from s 0 c \&. .sp Raise .B Invalid_argument if .B i is not a valid position in .B s \&. Raise .B Not_found if .B c does not occur in .B s after position .B i \&. .sp .I val index_from_opt : .B bytes -> int -> char -> int option .sp .B index_from _opts i c returns the index of the first occurrence of byte .B c in .B s after position .B i or .B None if .B c does not occur in .B s after position .B i \&. .B Bytes\&.index_opt s c is equivalent to .B Bytes\&.index_from_opt s 0 c \&. .sp Raise .B Invalid_argument if .B i is not a valid position in .B s \&. .sp .B "Since" 4.05 .sp .I val rindex_from : .B bytes -> int -> char -> int .sp .B rindex_from s i c returns the index of the last occurrence of byte .B c in .B s before position .B i+1 \&. .B rindex s c is equivalent to .B rindex_from s (Bytes\&.length s \- 1) c \&. .sp Raise .B Invalid_argument if .B i+1 is not a valid position in .B s \&. Raise .B Not_found if .B c does not occur in .B s before position .B i+1 \&. .sp .I val rindex_from_opt : .B bytes -> int -> char -> int option .sp .B rindex_from_opt s i c returns the index of the last occurrence of byte .B c in .B s before position .B i+1 or .B None if .B c does not occur in .B s before position .B i+1 \&. .B rindex_opt s c is equivalent to .B rindex_from s (Bytes\&.length s \- 1) c \&. .sp Raise .B Invalid_argument if .B i+1 is not a valid position in .B s \&. .sp .B "Since" 4.05 .sp .I val contains : .B bytes -> char -> bool .sp .B contains s c tests if byte .B c appears in .B s \&. .sp .I val contains_from : .B bytes -> int -> char -> bool .sp .B contains_from s start c tests if byte .B c appears in .B s after position .B start \&. .B contains s c is equivalent to .B contains_from .B s 0 c \&. .sp Raise .B Invalid_argument if .B start is not a valid position in .B s \&. .sp .I val rcontains_from : .B bytes -> int -> char -> bool .sp .B rcontains_from s stop c tests if byte .B c appears in .B s before position .B stop+1 \&. .sp Raise .B Invalid_argument if .B stop < 0 or .B stop+1 is not a valid position in .B s \&. .sp .I val uppercase : .B bytes -> bytes .sp .B "Deprecated." Functions operating on Latin\-1 character set are deprecated\&. .sp Return a copy of the argument, with all lowercase letters translated to uppercase, including accented letters of the ISO Latin\-1 (8859\-1) character set\&. .sp .I val lowercase : .B bytes -> bytes .sp .B "Deprecated." Functions operating on Latin\-1 character set are deprecated\&. .sp Return a copy of the argument, with all uppercase letters translated to lowercase, including accented letters of the ISO Latin\-1 (8859\-1) character set\&. .sp .I val capitalize : .B bytes -> bytes .sp .B "Deprecated." Functions operating on Latin\-1 character set are deprecated\&. .sp Return a copy of the argument, with the first character set to uppercase, using the ISO Latin\-1 (8859\-1) character set\&.\&. .sp .I val uncapitalize : .B bytes -> bytes .sp .B "Deprecated." Functions operating on Latin\-1 character set are deprecated\&. .sp Return a copy of the argument, with the first character set to lowercase, using the ISO Latin\-1 (8859\-1) character set\&.\&. .sp .I val uppercase_ascii : .B bytes -> bytes .sp Return a copy of the argument, with all lowercase letters translated to uppercase, using the US\-ASCII character set\&. .sp .B "Since" 4.05.0 .sp .I val lowercase_ascii : .B bytes -> bytes .sp Return a copy of the argument, with all uppercase letters translated to lowercase, using the US\-ASCII character set\&. .sp .B "Since" 4.05.0 .sp .I val capitalize_ascii : .B bytes -> bytes .sp Return a copy of the argument, with the first character set to uppercase, using the US\-ASCII character set\&. .sp .B "Since" 4.05.0 .sp .I val uncapitalize_ascii : .B bytes -> bytes .sp Return a copy of the argument, with the first character set to lowercase, using the US\-ASCII character set\&. .sp .B "Since" 4.05.0 .sp .I type t = .B bytes .sp An alias for the type of byte sequences\&. .sp .I val compare : .B t -> t -> int .sp The comparison function for byte sequences, with the same specification as .B Pervasives\&.compare \&. Along with the type .B t , this function .B compare allows the module .B Bytes to be passed as argument to the functors .B Set\&.Make and .B Map\&.Make \&. .sp .I val equal : .B t -> t -> bool .sp The equality function for byte sequences\&. .sp .B "Since" 4.05.0 .sp