package stk

  1. Overview
  2. Docs

Handling UTF-8 strings.

val length : string -> int

Number of UTF-8 characters in string.

val rev_chars : ?acc:Uchar.t list -> string -> pos:int -> len:int -> Uchar.t list

rev_chars str ~pos ~len returns the list, in reverse order, of characters in str from pos to pos+len. If pos or len is invalid, an error message is logged but the function returns what it could find. Optional argument acc can be provided as initial accumulator.

val sub : string -> pos:int -> len:int -> string

sub str ~pos ~len returns substring of str from pos to pos+len. If pos or len is invalid, an error message is logged but t he function returns what it could find.

val blit : string -> int -> Uchar.t array -> int -> int -> int

blit str pos target pos_target len copies len characters from str beginning at position pos to target beginning at position pos_target. Returns the number of copied characters.

val cut : string -> pos:int -> len:int -> string * string * string

cut str ~pos ~len returns three strings, corresponding to contents of str before pos, contents of str between pos and pos+len, and contents of str after pos+len. Raises Invalid_argument if pos < 0.

val to_chunks : int -> string -> (int * string) list

to_chunks max_len str cuts str in chunks of max_len characters maximum.

val concat : string -> string -> string

concat s1 s2 concatenates s1 and s2.

val insert : string -> pos:int -> string -> string

insert str ~pos str2 returns a new string where str2 was inserted in str at position pos.

val normalize : string -> string

normalize str performs a `NFC normalization to return a new string. See Uunf_string.normalize_utf_8.

val string_of_uchar : Uchar.t -> string

string_of_uchar c returns the string corresponding to given Utf68 character c.

val map : (Uchar.t -> Uchar.t) -> string -> string

map f str returns a new string wmheree ach character of str was mapped by f.

OCaml

Innovation. Community. Security.