1Stdlib.Uchar(3) OCaml library Stdlib.Uchar(3)
2
3
4
6 Stdlib.Uchar - no description
7
9 Module Stdlib.Uchar
10
12 Module Uchar
13 : (module Stdlib__Uchar)
14
15
16
17
18
19
20
21 type t
22
23
24 The type for Unicode characters.
25
26 A value of this type represents a Unicode scalar value which is an in‐
27 teger in the ranges 0x0000 ... 0xD7FF or 0xE000 ... 0x10FFFF .
28
29
30
31 val min : t
32
33
34 min is U+0000.
35
36
37
38 val max : t
39
40
41 max is U+10FFFF.
42
43
44
45 val bom : t
46
47
48 bom is U+FEFF, the byte order mark (BOM) character.
49
50
51 Since 4.06.0
52
53
54
55 val rep : t
56
57
58 rep is U+FFFD, the replacement character.
59
60
61 Since 4.06.0
62
63
64
65 val succ : t -> t
66
67
68 succ u is the scalar value after u in the set of Unicode scalar values.
69
70
71 Raises Invalid_argument if u is Uchar.max .
72
73
74
75 val pred : t -> t
76
77
78 pred u is the scalar value before u in the set of Unicode scalar val‐
79 ues.
80
81
82 Raises Invalid_argument if u is Uchar.min .
83
84
85
86 val is_valid : int -> bool
87
88
89 is_valid n is true if and only if n is a Unicode scalar value (i.e. in
90 the ranges 0x0000 ... 0xD7FF or 0xE000 ... 0x10FFFF ).
91
92
93
94 val of_int : int -> t
95
96
97 of_int i is i as a Unicode character.
98
99
100 Raises Invalid_argument if i does not satisfy Uchar.is_valid .
101
102
103
104 val to_int : t -> int
105
106
107 to_int u is u as an integer.
108
109
110
111 val is_char : t -> bool
112
113
114 is_char u is true if and only if u is a latin1 OCaml character.
115
116
117
118 val of_char : char -> t
119
120
121 of_char c is c as a Unicode character.
122
123
124
125 val to_char : t -> char
126
127
128 to_char u is u as an OCaml latin1 character.
129
130
131 Raises Invalid_argument if u does not satisfy Uchar.is_char .
132
133
134
135 val equal : t -> t -> bool
136
137
138 equal u u' is u = u' .
139
140
141
142 val compare : t -> t -> int
143
144
145 compare u u' is Stdlib.compare u u' .
146
147
148
149 val hash : t -> int
150
151
152 hash u associates a non-negative integer to u .
153
154
155
156
157 UTF codecs tools
158 type utf_decode
159
160
161 The type for UTF decode results. Values of this type represent the re‐
162 sult of a Unicode Transformation Format decoding attempt.
163
164
165
166 val utf_decode_is_valid : utf_decode -> bool
167
168
169 utf_decode_is_valid d is true if and only if d holds a valid decode.
170
171
172
173 val utf_decode_uchar : utf_decode -> t
174
175
176 utf_decode_uchar d is the Unicode character decoded by d if utf_de‐
177 code_is_valid d is true and Uchar.rep otherwise.
178
179
180
181 val utf_decode_length : utf_decode -> int
182
183
184 utf_decode_length d is the number of elements from the source that were
185 consumed by the decode d . This is always strictly positive and smaller
186 or equal to 4 . The kind of source elements depends on the actual de‐
187 coder; for the decoders of the standard library this function always
188 returns a length in bytes.
189
190
191
192 val utf_decode : int -> t -> utf_decode
193
194
195 utf_decode n u is a valid UTF decode for u that consumed n elements
196 from the source for decoding. n must be positive and smaller or equal
197 to 4 (this is not checked by the module).
198
199
200
201 val utf_decode_invalid : int -> utf_decode
202
203
204 utf_decode_invalid n is an invalid UTF decode that consumed n elements
205 from the source to error. n must be positive and smaller or equal to 4
206 (this is not checked by the module). The resulting decode has Uchar.rep
207 as the decoded Unicode character.
208
209
210
211 val utf_8_byte_length : t -> int
212
213
214 utf_8_byte_length u is the number of bytes needed to encode u in UTF-8.
215
216
217
218 val utf_16_byte_length : t -> int
219
220
221 utf_16_byte_length u is the number of bytes needed to encode u in
222 UTF-16.
223
224
225
226
227
228OCamldoc 2023-01-23 Stdlib.Uchar(3)