mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
add Char.{of_int{,_exn},to_int} (close #95)
This commit is contained in:
parent
126bb2f3f2
commit
8462b89bdf
2 changed files with 17 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue