module Encoding: sig
.. end
Character encodings
type
t = string
Type of a character encoding
val system : t
The character encoding used by the system
type
code_point = int
Type of a unicode code-point.
val recode_string : ?fallback:string -> src:t -> dst:t -> string -> string
recode_string ?fallback ~src ~dst str
recode str
from src
encoding to dst
encoding. If fallback
is provided then
characters that cannot be encoded are replaced by fallback
(which must be in src
encoding).
Decoding
type
decoder
Type of a decoder
val decoder : t -> decoder
Creates a decoder from an encoding-name
type
decoding_result =
| |
Dec_ok of code_point * int |
| |
Dec_need_more |
| |
Dec_error |
Result of a decoding operation
val decode : decoder -> string -> int -> int -> decoding_result
decode decoder buffer ptr len
decodes with decoder
bytes at
position ptr
in buffer
Encoding
type
encoder
Type of an encoder
val encoder : t -> encoder
Creates an encoder from an encoding-name
type
encoding_result =
| |
Enc_ok of int |
| |
Enc_need_more |
| |
Enc_error |
Result of an encoding operation
val encode : encoder ->
string -> int -> int -> code_point -> encoding_result
encode decoder buffer ptr len code
encodes code
with
encoder
at position ptr
in buffer