add Char.{of_int{,_exn},to_int} (close #95)

This commit is contained in:
Simon Cruanes 2017-01-30 14:46:13 +01:00
parent 126bb2f3f2
commit 8462b89bdf
2 changed files with 17 additions and 0 deletions

View file

@ -12,6 +12,10 @@ let compare = Char.compare
let pp = Buffer.add_char
let print = Format.pp_print_char
let of_int_exn = Char.chr
let of_int c = try Some (of_int_exn c) with _ -> None
let to_int = Char.code
let lowercase_ascii c =
if c >= 'A' && c <= 'Z'
then Char.unsafe_chr (Char. code c + 32)

View file

@ -17,5 +17,18 @@ val uppercase_ascii : t -> t
(** See {!Char}
@since 0.20 *)
val of_int_exn : int -> t
(** Alias to {!Char.chr}
@raise Invalid_argument if the int is not within [0,...,255]
@since NEXT_RELEASE *)
val of_int : int -> t option
(** Safe version of {!of_int}
@since NEXT_RELEASE *)
val to_int : t -> int
(** Alias to {!Char.code}
@since NEXT_RELEASE *)
val pp : Buffer.t -> t -> unit
val print : Format.formatter -> t -> unit