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.
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.
All functions below assume strings are valid UTF-16. If not, the result is unspecified.
Positions in the string represented by the number of 16-bit unit
from the head.
The location of the first character is 0
next s i
returns the position of the head of the Unicode character
located immediately after i
.
i
is a valid position, the function always success.i
is a valid position and there is no Unicode character after i
,
the position outside s
is returned.i
is not a valid position, the behaviour is undefined.prev s i
returns the position of the head of the Unicode character
located immediately before i
.
i
is a valid position, the function always success.i
is a valid position and there is no Unicode character before i
,
the position outside s
is returned.i
is not a valid position, the behaviour is undefined.