aboutsummaryrefslogtreecommitdiff
path: root/src/UTF8.mli
blob: bd736234aa329a0cf50a21538ef26cf90e8a78d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
(*
This file is part of licht.

licht is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

licht is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with licht.  If not, see <http://www.gnu.org/licenses/>.
*)

(** UTF8 is used internally for all strings

  The module is intentionaly opaque.

 *)

(** An UTF8 encoded string *)
type t

val empty: t

(** Decode a string in the current locale *)
val decode: string -> t

(** Use this to with a known UTF8 encoded string *)
val from_utf8string: string -> t

(** Encode to the string to the user locale *)
val encode: t -> string option

(** Encode the string.
    This function may raise Text.Invalid if the string cannot be encoded in current locale
*)
val raw_encode: t -> string

val to_utf8string: t -> string

val trim: t -> t

val length: t -> int

val get: t -> int -> t

val rev_explode : t -> t list

val split: t -> sep:t -> t

val fold : (t -> 'a -> 'a) -> t -> 'a -> 'a

val implode : t list -> t

val rev_implode : t list -> t

val compare: t -> t -> int

val replace: t -> t -> t -> t

val upper: t -> t

val lower: t -> t

val code: t -> int

val char: int -> t

val repeat: int -> t -> t

val get: t -> int -> t

val lchop: t -> t

val rchop: t -> t

val sub: t -> int -> int -> t

module Buffer : sig

  type buffer

  val create : int -> buffer

  val contents : buffer -> t

  val add_string : buffer -> t -> unit

  val add_char: buffer -> char -> unit

end

module Printf : sig

  val bprintf : Buffer.buffer -> ('a, Buffer.buffer, unit) format -> 'a

end

module Format: sig

  val formatter_of_buffer : Buffer.buffer -> Format.formatter

  val fprintf : Format.formatter -> ('a, Format.formatter, unit) format -> 'a

end