
include Uchar


(*
let rep' = 0xFFFD

type utf_decode = int

let valid_bit = 27
let decode_bits = 24

let utf_decode_is_valid d = (d lsr valid_bit) = 1
let utf_decode_length d = (d lsr decode_bits) land 0b111
let utf_decode_uchar d = unsafe_of_int (d land 0xFFFFFF)
let utf_decode n u = ((8 lor n) lsl decode_bits) lor (to_int u)
let utf_decode_invalid n = (n lsl decode_bits) lor rep'

let utf_8_byte_length u = match to_int u with
| u when u < 0 -> assert false
| u when u <= 0x007F -> 1
| u when u <= 0x07FF -> 2
| u when u <= 0xFFFF -> 3
| u when u <= 0x10FFFF -> 4
| _ -> assert false

let utf_16_byte_length u = match to_int u with
| u when u < 0 -> assert false
| u when u <= 0xFFFF -> 2
| u when u <= 0x10FFFF -> 4
| _ -> assert false
*)

(*
let bom = unsafe_of_int 0xFEFF

let rep = unsafe_of_int rep'
*)


external seeded_hash_param :
  int -> int -> int -> 'a -> int = "caml_hash" [@@noalloc]
let seeded_hash seed x = seeded_hash_param 10 100 seed x

