package mrmime

  1. Overview
  2. Docs
type charset = [
  1. | `UTF_8
  2. | `UTF_16
  3. | `UTF_16BE
  4. | `UTF_16LE
  5. | Rosetta.encoding
  6. | `US_ASCII
  7. | `Charset of string
]
type encoding =
  1. | Quoted_printable
  2. | Base64
val b : encoding

Base64 encoding.

val q : encoding

Inline quoted-printable encoding.

type t = {
  1. charset : charset;
  2. encoding : encoding;
  3. data : (string, [ `Msg of string ]) result;
}
val is_normalized : t -> bool
val make : encoding:encoding -> string -> (t, [ `Msg of string ]) result

make ~encoding x returns an encoded word according encoding (Quoted Printable encoding or Base64 encoding). x must be a valid UTF-8 string. charset of encoded word will be, by the way, "UTF-8".

NOTE: If you expect to generate an encoded word with something else than UTF-8 (like latin1), we decided to not handle this case and just produce valid UTF-8 contents in any cases.

val make_exn : encoding:encoding -> string -> t

Alias of make but raises an Invalid_argument if it fails.

Accessors.

val encoding : t -> encoding
val charset : t -> charset
val data : t -> (string, [ `Msg of string ]) result

Pretty-printer.

val pp_charset : Format.formatter -> charset -> unit
val pp_encoding : Format.formatter -> encoding -> unit
val pp : Format.formatter -> t -> unit

Equal.

val equal_charset : charset -> charset -> bool
val equal_encoding : encoding -> encoding -> bool
val equal : t -> t -> bool
val charset_of_string : string -> charset

charset_of_string s returns charset of well-formed charset identifier s (according IANA).

val charset_to_string : charset -> string
val normalize_to_utf8 : charset:charset -> string -> (string, [ `Msg of string ]) result

normalize_to_utf8 ~charset s maps a source s which is encoded with the charset charset and try to map/normalize it to UTF-8.

val of_string : string -> (t, [ `Msg of string ]) result

of_string v tries to parse v as an encoded-word (according RFC 2047).

Decoders.

module Decoder : sig ... end

Encoders.

module Encoder : sig ... end
OCaml

Innovation. Community. Security.