123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081open!Importletfailwithf=Printf.failwithfmoduleT=structincludeUchar0letmodule_name="Base.Uchar"lethash_fold_tstatet=Hash.fold_intstate(to_intt)lethasht=Hash.runhash_fold_ttletto_stringt=Printf.sprintf"U+%04X"(to_intt)(* Do not actually export this. See discussion in the .mli *)letsexp_of_tt=Sexp.Atom(to_stringt)lett_of_sexpsexp=matchsexpwith|Sexp.List_->of_sexp_error"Uchar.t_of_sexp: atom needed"sexp|Sexp.Atoms->tryCaml.Scanf.sscanfs"U+%X"(funi->Uchar0.of_inti)with_->of_sexp_error"Uchar.t_of_sexp: atom of the form U+XXXX needed"sexpendincludeTincludePretty_printer.Register(T)includeComparable.Make(T)(* Open replace_polymorphic_compare after including functor instantiations so they do not
shadow its definitions. This is here so that efficient versions of the comparison
functions are available within this module. *)open!Uchar_replace_polymorphic_compareletint_is_scalar=is_validletsucc_exnc=tryUchar0.succcwithInvalid_argumentmsg->failwithf"Uchar.succ_exn: %s"msg()letsuccc=trySome(Uchar0.succc)withInvalid_argument_->Noneletpred_exnc=tryUchar0.predcwithInvalid_argumentmsg->failwithf"Uchar.pred_exn: %s"msg()letpredc=trySome(Uchar0.predc)withInvalid_argument_->Noneletof_scalari=ifint_is_scalarithenSome(unsafe_of_inti)elseNoneletof_scalar_exni=ifint_is_scalarithenunsafe_of_intielsefailwithf"Uchar.of_int_exn got a invalid Unicode scalar value: %04X"i()letto_scalart=Uchar0.to_inttletto_charc=ifis_charcthenSome(unsafe_to_charc)elseNoneletto_char_exnc=ifis_charcthenunsafe_to_charcelsefailwithf"Uchar.to_char_exn got a non latin-1 character: U+%04X"(to_intc)()(* Include type-specific [Replace_polymorphic_compare] at the end, after
including functor application that could shadow its definitions. This is
here so that efficient versions of the comparison functions are exported by
this module. *)includeUchar_replace_polymorphic_compare