Module OgamlUtils.UTF8String

UTF-8 String representation and manipulation
type code = int
Type of a UTF-8 character code
type t
Type of a UTF-8 encoded string
exception UTF8_error of string
Raised when a string is not correctly encoded
exception Out_of_bounds of string
Raised when an operation violates the bounds of the string
val empty : unit -> t
Empty UTF-8 string
val make : int -> code -> t
Makes a UTF-8 string filled with one character
Raises UTF8_error if the code is not a valid UTF-8 character code
val get : t -> int -> code
Returns the ith character of a UTF-8 string
val set : t -> int -> code -> unit
Sets the ith character of a UTF-8 string.
Raises UTF8_error if the code is not a valid UTF-8 character code
val length : t -> int
Returns the length of a UTF-8 string
val byte_length : t -> int
Returns the byte length of a UTF-8 string (the number of bytes required to encode it)
val from_string : string -> t
Returns a UTF-8 encoded string from a string.
Raises UTF8_error if the string is not a valid UTF-8 encoding
val to_string : t -> string
Returns a string from a UTF-8 encoded string
val iter : t -> (code -> unit) -> unit
Iterates through a UTF-8 string
val fold : t -> (code -> 'a -> 'a) -> 'a -> 'a
Folds a UTF-8 string
val map : t -> (code -> code) -> t
Maps a UTF-8 string
Raises UTF8_error if the function returns an invalid UTF-8 code