type (='a:level, #'b:level) t = ('a, 'b) charray
val length : ('a, 'b) t -> 'b int
Return the length (number of characters) of the given string.
val get : ('a, 'b) t -> 'b int -> 'b char
with 'a < 'b
Charray.get s n
returns character number n
in string s
.
The first character is character number 0.
The last character is character number Charray.length s - 1
.
Terminate the program if n
is outside the range
0 to (Charray.length s - 1)
.
You can also write s.[n]
instead of Charray.get s n
.
val set : ('a, 'a) t -> 'a int -> 'a char -{'a ||}-> unit
Charray.set s n c
modifies string s
in place,
replacing the character number n
by c
.
Terminate the program if n
is outside the range
0 to (Charray.length s - 1)
.
You can also write s.[n] <- c
instead of Charray.set s n c
.
val make : 'a int -> 'b char -> ('b, 'a) t
Charray.make n c
returns a fresh string of length n
,
filled with the character c
.
Terminate the program if n < 0
or n >
Sys.max_string_length
.
val copy : ('a, 'b) t -> ('c, 'b) t
with 'a < 'c
Return a copy of the given string.
val sub : ('a, 'b) t -> 'b int -> 'b int -> ('c, 'b) t
with 'a, 'b < 'c
Charray.sub s start len
returns a fresh string of length len
,
containing the characters number start
to start + len - 1
of string s
.
Terminate the program if start
and len
do not
designate a valid substring of s
; that is, if start < 0
,
or len < 0
, or start + len >
Charray.length
s
.
val fill : ('a, 'a) t -> 'a int -> 'a int -> 'a char -{'a ||}-> unit
Charray.fill s start len c
modifies string s
in place,
replacing the characters number start
to start + len - 1
by c
.
Terminate the program if start
and len
do not
designate a valid substring of s
.
val blit : ('a, 'b) t ->
'b int -> ('b, 'b) t -> 'b int -> 'b int -{'b ||}-> unit
with 'a < 'b
Charray.blit src srcoff dst dstoff len
copies len
characters
from string src
, starting at character number srcoff
, to
string dst
, starting at character number dstoff
. It works
correctly even if src
and dst
are the same string,
and the source and destination chunks overlap.
Terminate the program if srcoff
and len
do not
designate a valid substring of src
, or if dstoff
and len
do not designate a valid substring of dst
.
val concat : ('a, 'b) t -> (('c, 'b) t, 'b) list -> ('d, 'b) t
with 'a, 'b, 'c < 'd
Charray.concat sep sl
concatenates the list of strings sl
,
inserting the separator string sep
between each.
val iter : ('a char -{'b | 'c | 'b}-> unit) -> ('d, 'e) t -{'b | 'c |}-> unit
with content('c), 'e < 'b
and 'd, 'e < 'a
Charray.iter f s
applies function f
in turn to all
the characters of s
. It is equivalent to
f s.(0); f s.(1); ...; f s.(Charray.length s - 1); ()
.
val escaped : ('a, 'b) t -> ('c, 'b) t
with 'a < 'b, 'c
Return a copy of the argument, with special characters
represented by escape sequences, following the lexical
conventions of Objective Caml. If there is no special
character in the argument, return the original string itself,
not a copy.
val index : ('a, 'b) t -> 'b char -{'c | Not_found: 'c |}-> 'd int
with 'b < 'c, 'd
and 'a < 'c, 'd
Charray.index s c
returns the position of the leftmost
occurrence of character c
in string s
.
Raise Not_found
if c
does not occur in s
.
val rindex : ('a, 'b) t -> 'b char -{'c | Not_found: 'c |}-> 'd int
with 'b < 'c, 'd
and 'a < 'c, 'd
Charray.rindex s c
returns the position of the rightmost
occurrence of character c
in string s
.
Raise Not_found
if c
does not occur in s
.
val index_from : ('a, 'b) t ->
'b int -> 'b char -{'c | Not_found: 'c |}-> 'd int
with 'b < 'c, 'd
and 'a < 'c, 'd
Same as Charray.index
, but start
searching at the character position given as second argument.
Charray.index s c
is equivalent to Charray.index_from s 0 c
.
val rindex_from : ('a, 'b) t ->
'b int -> 'b char -{'c | Not_found: 'c |}-> 'd int
with 'b < 'c, 'd
and 'a < 'c, 'd
Same as Charray.rindex
, but start
searching at the character position given as second argument.
Charray.rindex s c
is equivalent to
Charray.rindex_from s (Charray.length s - 1) c
.
val contains : ('a, 'b) t -> 'b char -> 'b bool
with 'a < 'b
Charray.contains s c
tests if character c
appears in the string s
.
val contains_from : ('a, 'b) t -> 'b int -> 'b char -> 'b bool
with 'a < 'b
Charray.contains_from s start c
tests if character c
appears in the substring of s
starting from start
to the end
of s
.
Terminate the program if start
is not a valid index of s
.
val rcontains_from : ('a, 'b) t -> 'b int -> 'b char -> 'b bool
with 'a < 'b
Charray.rcontains_from s stop c
tests if character c
appears in the substring of s
starting from the beginning
of s
to index stop
.
Terminate the program if stop
is not a valid index of s
.
val uppercase : ('a, 'b) t -> ('a, 'b) t
Return a copy of the argument, with all lowercase letters
translated to uppercase, including accented letters of the ISO
Latin-1 (8859-1) character set.
val lowercase : ('a, 'b) t -> ('a, 'b) t
Return a copy of the argument, with all uppercase letters
translated to lowercase, including accented letters of the ISO
Latin-1 (8859-1) character set.
val capitalize : ('a, 'b) t -> ('a, 'b) t
Return a copy of the argument, with the first letter set to uppercase.
val uncapitalize : ('a, 'b) t -> ('a, 'b) t
Return a copy of the argument, with the first letter set to lowercase.