Module Main.Type.UTF16


module UTF16: sig .. end

type t = (int, Bigarray.int16_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t 
UTF-16 encoded string. the type is the bigarray of 16-bit integers. The characters must be 21-bits code points, and not surrogate points, 0xfffe, 0xffff. Bigarray.cma or Bigarray.cmxa must be linked when this module is used.
exception Malformed_code
validate s If s is valid UTF-16 then successes otherwise raises Malformed_code. Other functions assume strings are valid UTF-16, so it is prudent to test their validity for strings from untrusted origins.
val validate : t -> unit
All functions below assume strings are valid UTF-16. If not, the result is unspecified.
val get : t -> int -> Main.Type.UChar.t
get s n returns n-th Unicode character of s. The call requires O(n)-time.
exception Out_of_range
init len f returns a new string which contains len Unicode characters. The i-th Unicode character is initialized by f i if the character is not representable, raise Out_of_range.
val init : int -> (int -> Main.Type.UChar.t) -> t
length s returns the number of Unicode characters contained in s
val length : t -> int
Positions in the string represented by the number of 16-bit unit from the head. The location of the first character is 0
type index = int 
nth s n returns the position of the n-th Unicode character. The call requires O(n)-time
val nth : t -> int -> index
first s : The position of the head of the last Unicode character.
val first : t -> index
last s : The position of the head of the last Unicode character.
val last : t -> index
look s i returns the Unicode character of the location i in the string s.
val look : t -> index -> Main.Type.UChar.t
out_of_range s i tests whether i is inside of s.
val out_of_range : t -> index -> bool
compare_aux s i1 i2 returns
val compare_index : t -> index -> index -> int
next s i returns the position of the head of the Unicode character located immediately after i.
val next : t -> index -> index
prev s i returns the position of the head of the Unicode character located immediately before i.
val prev : t -> index -> index
val move : t -> index -> int -> index
iter f s Apply f to all Unicode characters in s. The order of application is same to the order in the Unicode characters in s.
val iter : (Main.Type.UChar.t -> unit) -> t -> unit
Code point comparison
val compare : t -> t -> int
Buffer module for UTF-16
module Buf: sig .. end