17 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 |
*) |
*) |
19 |
|
|
20 |
|
type uchar = int |
21 |
|
|
22 |
type charset = |
type charset = |
23 |
| ANSI_X3_4_1968 | ANSI_X3_4_1986 | ASCII | CP367 | IBM367 | ISO_IR_6 | ISO646_US | ISO_646_IRV_1991 | US | US_ASCII | CSASCII |
| ANSI_X3_4_1968 | ANSI_X3_4_1986 | ASCII | CP367 | IBM367 | ISO_IR_6 | ISO646_US | ISO_646_IRV_1991 | US | US_ASCII | CSASCII |
24 |
| UTF_8 |
| UTF_8 |
138 |
| I_869 | CP_GR | CP869 | IBM869 | CSIBM869 |
| I_869 | CP_GR | CP869 | IBM869 | CSIBM869 |
139 |
| CP1125 |
| CP1125 |
140 |
|
|
141 |
(* convert ~from_charset ~to_charset s : |
(** [convert ~from_charset ~to_charset s] |
142 |
* raise CharsetError if the string [s] is not entirely convertible. |
raise CharsetError if the string s is not entirely convertible. *) |
|
*) |
|
|
|
|
143 |
val convert : from_charset : charset -> to_charset : charset -> string -> string |
val convert : from_charset : charset -> to_charset : charset -> string -> string |
144 |
|
|
145 |
|
(** [is_utf8 s] |
146 |
|
returns TRUE if s is a valid UTF-8, otherwise returns FALSE. |
147 |
|
Other functions assume strings are valid UTF-8, so it is prudent |
148 |
|
to test their validity for strings from untrusted origins. *) |
149 |
val is_utf8 : string -> bool |
val is_utf8 : string -> bool |
150 |
|
|
151 |
|
(** [to_utf8 s] |
152 |
|
Converts the input string to UTF-8. *) |
153 |
val to_utf8 : string -> string |
val to_utf8 : string -> string |
154 |
|
|
155 |
|
(** [to_locale s] |
156 |
|
Converts the input string to the encoding of the current locale. *) |
157 |
val to_locale : string -> string |
val to_locale : string -> string |
158 |
|
|
159 |
|
(** [utf8_get s n] |
160 |
|
returns [n]-th Unicode character of [s]. |
161 |
|
The call requires O(n)-time. *) |
162 |
|
val utf8_get : string -> int -> uchar |
163 |
|
|
164 |
|
(** [utf8_length s] |
165 |
|
returns the number of Unicode characters contained in s *) |
166 |
|
val utf8_length : string -> int |
167 |
|
|
168 |
|
(** [add_uchar buf u] |
169 |
|
add one Unicode character to the buffer. *) |
170 |
|
val add_uchar : Buffer.t -> uchar -> unit |