package stdune

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t = string
include module type of struct include Stdlib.StringLabels end with type t := t
val make : int -> char -> string
val init : int -> f:(int -> char) -> string
val empty : string
val of_bytes : bytes -> string
val to_bytes : string -> bytes
val length : string -> int
val get : string -> int -> char
val concat : sep:string -> string list -> string
val cat : string -> string -> string
val starts_with : prefix:string -> string -> bool
val ends_with : suffix:string -> string -> bool
val contains_from : string -> int -> char -> bool
val rcontains_from : string -> int -> char -> bool
val contains : string -> char -> bool
val sub : string -> pos:int -> len:int -> string
val split_on_char : sep:char -> string -> string list
val map : f:(char -> char) -> string -> string
val mapi : f:(int -> char -> char) -> string -> string
val fold_left : f:('a -> char -> 'a) -> init:'a -> string -> 'a
val fold_right : f:(char -> 'a -> 'a) -> string -> init:'a -> 'a
val trim : string -> string
val escaped : string -> string
val uppercase_ascii : string -> string
val lowercase_ascii : string -> string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val iter : f:(char -> unit) -> string -> unit
val iteri : f:(int -> char -> unit) -> string -> unit
val index_from_opt : string -> int -> char -> int option
val rindex_from_opt : string -> int -> char -> int option
val index_opt : string -> char -> int option
val rindex_opt : string -> char -> int option
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 is_valid_utf_8 : t -> bool
val get_utf_16be_uchar : t -> int -> Stdlib.Uchar.utf_decode
val is_valid_utf_16be : t -> bool
val get_utf_16le_uchar : t -> int -> Stdlib.Uchar.utf_decode
val is_valid_utf_16le : t -> bool
val blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit
val get_uint8 : string -> int -> int
val get_int8 : string -> int -> int
val get_uint16_ne : string -> int -> int
val get_uint16_be : string -> int -> int
val get_uint16_le : string -> int -> int
val get_int16_ne : string -> int -> int
val get_int16_be : string -> int -> int
val get_int16_le : string -> int -> int
val get_int32_ne : string -> int -> int32
val seeded_hash : int -> t -> int
val get_int32_be : string -> int -> int32
val get_int32_le : string -> int -> int32
val get_int64_ne : string -> int -> int64
val get_int64_be : string -> int -> int64
val get_int64_le : string -> int -> int64
val unsafe_get : string -> int -> char
val unsafe_blit : src:string -> src_pos:int -> dst:bytes -> dst_pos:int -> len:int -> unit
val equal : t -> t -> bool
val compare : t -> t -> Ordering.t
val hash : t -> int
val to_dyn : t -> Dyn.t
val break : t -> pos:int -> t * t
val is_empty : t -> bool
val of_list : char list -> t
val is_prefix : t -> prefix:t -> bool
val is_suffix : t -> suffix:t -> bool
val take : t -> int -> t
val drop : t -> int -> t
val split_n : t -> int -> t * t
val drop_prefix : t -> prefix:t -> t option
val drop_prefix_if_exists : t -> prefix:t -> t
val drop_suffix : t -> suffix:t -> t option
val drop_suffix_if_exists : t -> suffix:t -> t
val capitalize : t -> t

These only change ASCII characters

val uncapitalize : t -> t
val uppercase : t -> t
val lowercase : t -> t
val index : t -> char -> int option
val index_from : t -> int -> char -> int option
val rindex : t -> char -> int option
val rindex_from : t -> int -> char -> int option
val extract_words : t -> is_word_char:(char -> bool) -> t list
val extract_comma_space_separated_words : t -> t list
val extract_blank_separated_words : t -> t list
val lsplit2 : t -> on:char -> (t * t) option
val lsplit2_exn : t -> on:char -> t * t
val rsplit2 : t -> on:char -> (t * t) option
val split : t -> on:char -> t list
val split_lines : t -> t list
val escape_only : char -> t -> t

Escape ONLY one character. escape also escapes '\n',... and transforms all chars above '~' into '\xxx' which is not suitable for UTF-8 strings.

val longest : string list -> int

Return the length of the longest string in the list

val longest_map : 'a list -> f:('a -> string) -> int
val longest_prefix : t list -> t
val exists : t -> f:(char -> bool) -> bool
val for_all : t -> f:(char -> bool) -> bool
val maybe_quoted : t -> t

maybe_quoted s is s if s doesn't need escaping according to OCaml lexing conventions and sprintf "%S" s otherwise.

(* CR-someday aalekseyev: this function is not great: barely anything "needs escaping according to OCaml lexing conventions", so the condition for whether to add the quote characters ends up being quite arbitrary. *)

val quoted : t -> t
val enumerate_and : string list -> string

Produces: "x, y and z"

val enumerate_or : string list -> string

Produces: "x, y or z"

val enumerate_one_of : t list -> t

Produces: "One of x, y or z"

val findi : string -> f:(char -> bool) -> int option

Find index of first character satisfying f

val rfindi : string -> f:(char -> bool) -> int option

Find index of last character satisfying f

include Comparable_intf.S with type key := t
module Map : sig ... end
module Set : sig ... end
module Table : Hashtbl.S with type key = t
val need_quoting : string -> bool

Whether the string needs quoting if it is part of a shell command

val quote_for_shell : string -> string

quote_for_shell s quotes s using Filename.quote if need_quoting s is true

val filter_map : string -> f:(char -> char option) -> string
OCaml

Innovation. Community. Security.