Uchar(3)
okay so this is Uchar(3), straight from the OCaml library manual, and it's literally the module for Unicode characters. bestie, we're about to get into scalar values, UTF decodes, and hash functions β no cap, it's giving foundational π
π NAME π
Uchar - Unicode characters.
π¦ Module π¦
the module line is literally:
Module Module Uchar
yes, it says Module twice. iconic.
β¨ Documentation β¨
the signature is literally:
Module Uchar
: sig end
Unicode characters.
Since 4.03
type tβ the type for Unicode characters. A value of this type represents a Unicode scalar value which is an integer in the ranges0x0000 ... 0xD7FFor0xE000 ... 0x10FFFF.val min : tβminisU+0000.val max : tβmaxisU+10FFFF.val bom : tβbomisU+FEFF, the byte order mark (BOM) character. Since 4.06val rep : tβrepisU+FFFD, the replacement character. Since 4.06val succ : t -> tβsucc uis the scalar value afteruin the set of Unicode scalar values. RaisesInvalid_argumentifuisUchar.max.val pred : t -> tβpred uis the scalar value beforeuin the set of Unicode scalar values. RaisesInvalid_argumentifuisUchar.min.val is_valid : int -> boolβis_valid nistrueif and only ifnis a Unicode scalar value (i.e. in the ranges0x0000 ... 0xD7FFor0xE000 ... 0x10FFFF).val of_int : int -> tβof_int iisias a Unicode character. RaisesInvalid_argumentifidoes not satisfyUchar.is_valid.val to_int : t -> intβto_int uisuas an integer.val is_char : t -> boolβis_char uistrueif and only ifuis a latin1 OCaml character.val of_char : char -> tβof_char ciscas a Unicode character.val to_char : t -> charβto_char uisuas an OCaml latin1 character. RaisesInvalid_argumentifudoes not satisfyUchar.is_char.val equal : t -> t -> boolβequal u u'isu = u'.val compare : t -> t -> intβcompare u u'isStdlib.compare u u'.val seeded_hash : int -> t -> intβseeded_hash seed uis a seeded hash function with the same output value asHashtbl.seeded_hash. This function allows this module to be passed as an argument to the functorHashtbl.MakeSeeded. Since 5.3val hash : t -> intβ an unseeded hash function with the same output value asHashtbl.hash. This function allows this module to be passed as an argument to the functorHashtbl.Make.Before5.3β the hashing algorithm was different. UseHashtbl.rebuildfor stored tables which used this hashing function.
π UTF codecs tools π
type utf_decodeβ the type for UTF decode results. Values of this type represent the result of a Unicode Transformation Format decoding attempt.val utf_decode_is_valid : utf_decode -> boolβutf_decode_is_valid distrueif and only ifdholds a valid decode.val utf_decode_uchar : utf_decode -> tβutf_decode_uchar dis the Unicode character decoded bydifutf_decode_is_valid distrueandUchar.repotherwise.val utf_decode_length : utf_decode -> intβutf_decode_length dis the number of elements from the source that were consumed by the decoded. This is always strictly positive and smaller or equal to4. The kind of source elements depends on the actual decoder; for the decoders of the standard library this function always returns a length in bytes.val utf_decode : int -> t -> utf_decodeβutf_decode n uis a valid UTF decode foruthat consumednelements from the source for decoding.nmust be positive and smaller or equal to4(this is not checked by the module).val utf_decode_invalid : int -> utf_decodeβutf_decode_invalid nis an invalid UTF decode that consumednelements from the source to error.nmust be positive and smaller or equal to4(this is not checked by the module). The resulting decode hasUchar.repas the decoded Unicode character.val utf_8_decode_length_of_byte : char -> intβutf_8_decode_length_of_byte byteis the number of bytes, from1toUchar.max_utf_8_decode_length, that a valid UTF-8 decode starting with bytebytewould consume or0ifbytecannot start a valid decode. Since 5.4val max_utf_8_decode_length : intβmax_utf_8_decode_lengthis4, the maximal number of bytes a valid or invalid UTF-8 decode can consume. Since 5.4val utf_8_byte_length : t -> intβutf_8_byte_length uis the number of bytes needed to encodeuin UTF-8.val utf_16_byte_length : t -> intβutf_16_byte_length uis the number of bytes needed to encodeuin UTF-16.
mwah π β generated by OCamldoc on 2026-06-22, and this was Uchar(3). slay, bye π«Ά
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms