package camomile

  1. Overview
  2. Docs
A Unicode library

Install

dune-project
 Dependency

Authors

Maintainers

Sources

camomile-1.0.2.tbz
sha256=f0a419b0affc36500f83b086ffaa36c545560cee5d57e84b729e8f851b3d1632
sha512=7586422e68779476206027c6ebbe19b677fbe459153221f7c952c7fae374c5c8232249cb76fdb1f482069707aa1580be827cd39693906142988268b7f0e7f6d0

doc/camomile.library/CamomileLibrary/module-type-Type/UTF16/index.html

Module Type.UTF16Source

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.

Sourceexception Malformed_code
Sourceval validate : t -> unit

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.

Sourceval get : t -> int -> UChar.t

get s n returns n-th Unicode character of s. The call requires O(n)-time.

Sourceexception Out_of_range
Sourceval init : int -> (int -> UChar.t) -> t

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.

Sourceval length : t -> int

length s returns the number of Unicode characters contained in s

Sourcetype index = int

Positions in the string represented by the number of 16-bit unit from the head. The location of the first character is 0

Sourceval nth : t -> int -> index

nth s n returns the position of the n-th Unicode character. The call requires O(n)-time

Sourceval first : t -> index

first s : The position of the head of the last Unicode character.

Sourceval last : t -> index

last s : The position of the head of the last Unicode character.

Sourceval look : t -> index -> UChar.t

look s i returns the Unicode character of the location i in the string s.

Sourceval out_of_range : t -> index -> bool

out_of_range s i tests whether i is inside of s.

Sourceval compare_index : t -> index -> index -> int

compare_aux s i1 i2 returns

  • If i1 is the position located before i2, a value < 0,
  • If i1 and i2 points the same location, 0,
  • If i1 is the position located after i2, a value > 0.
Sourceval next : t -> index -> index

next s i returns the position of the head of the Unicode character located immediately after i.

  • If i is a valid position, the function always success.
  • If i is a valid position and there is no Unicode character after i, the position outside s is returned.
  • If i is not a valid position, the behaviour is undefined.
Sourceval prev : t -> index -> index

prev s i returns the position of the head of the Unicode character located immediately before i.

  • If i is a valid position, the function always success.
  • If i is a valid position and there is no Unicode character before i, the position outside s is returned.
  • If i is not a valid position, the behaviour is undefined.
Sourceval move : t -> index -> int -> index
Sourceval iter : (UChar.t -> unit) -> t -> unit

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.

Sourceval compare : t -> t -> int

Code point comparison

Sourcemodule Buf = UTF16.Buf

Buffer module for UTF-16

OCaml

Innovation. Community. Security.