4
let of_seq g = Buffer.contents (Stdcompat__buffer.of_seq g)
6
let to_seq s = Stdcompat__tools.vec_to_seq length unsafe_get s
8
let to_seqi s = Stdcompat__tools.vec_to_seqi length unsafe_get s
13
Stdcompat__tools.option_find (index s) c
16
Stdcompat__tools.option_find (rindex s) c
18
let index_from_opt s i c =
19
Stdcompat__tools.option_find (index_from s i) c
21
let rindex_from_opt s i c =
22
Stdcompat__tools.option_find (rindex_from s i) c
26
let split_on_char c s =
27
let previous_index = ref (length s) in
29
for i = length s - 1 downto 0 do
30
if unsafe_get s i = c then
32
accu := sub s (i + 1) (!previous_index - i - 1) :: !accu;
36
sub s 0 !previous_index :: !accu
40
let lowercase_ascii = lowercase
42
let uppercase_ascii = uppercase
44
let capitalize_ascii = capitalize
46
let uncapitalize_ascii = uncapitalize
48
let equal : t -> t -> bool = ( = )
60
init (length s) (fun i -> f i (unsafe_get s i))
65
for i = 0 to length s - 1 do
70
init (length s) (fun i -> f (unsafe_get s i))
72
let is_space = function
73
| ' ' | '\012' | '\n' | '\r' | '\t' -> true
76
let rec rindex_no_space_from i s =
77
if i >= 0 && is_space (unsafe_get s i) then
78
rindex_no_space_from (pred i) s
82
let rec index_no_space_between i j s =
83
if i <= j && is_space (unsafe_get s i) then
84
index_no_space_between (succ i) j s
89
let off_end = rindex_no_space_from (length s - 1) s in
90
let off_start = index_no_space_between 0 off_end s in
91
if off_start > off_end then
93
else if off_start = 0 && off_end = length s - 1 then
96
sub s off_start (off_end - off_start + 1)