Misc.Utf8_lexeme(3)
π NAME π
okay so this is the Misc.Utf8_lexeme(3) page from the OCaml library manual, bestie. The official name line is Misc.Utf8_lexeme - no description. And likeβ¦ that's genuinely it for the description. No cap. π
π§ Module π§
Module Misc.Utf8_lexeme β yes queen, that's the module we're talking about. π
β¨ Documentation β¨
Module Utf8_lexeme
: sig end
πΈ type t πΈ
type t = string
Lowkey just a string, but make it fashion. π
π normalize π
val normalize : string -> (t, t) Result.t
Normalize the given UTF-8 encoded string. Invalid UTF-8 sequences results in a error and are replaced by U+FFFD. Identifier characters are put in NFC normalized form. Other Unicode characters are left unchanged. Slay. β¨
π capitalize π
val capitalize : string -> (t, t) Result.t
Like normalize, but if the string starts with a lowercase identifier character, it is replaced by the corresponding uppercase character. Subsequent characters are not changed. Periodt. π
π¦ uncapitalize π¦
val uncapitalize : string -> (t, t) Result.t
Like normalize, but if the string starts with an uppercase identifier character, it is replaced by the corresponding lowercase character. Subsequent characters are not changed. Cute. π
π is_capitalized π
val is_capitalized : t -> bool
Returns true if the given normalized string starts with an uppercase identifier character, false otherwise. May return wrong results if the string is not normalized. So likeβ¦ iykyk. π
π₯ is_valid_identifier π₯
val is_valid_identifier : t -> bool
Check whether the given normalized string is a valid OCaml identifier:
- -all characters are identifier characters
- -it does not start with a digit or a single quote
That's the vibe check for identifiers. β
πΈ is_lowercase πΈ
val is_lowercase : t -> bool
Returns true if the given normalized string only contains lowercase identifier character, false otherwise. May return wrong results if the string is not normalized. Again: iykyk, bestie. π
π§ type validation_result π§
type validation_result =
| Valid
| Invalid_character of Uchar.t
(* Character not allowed
*)
| Invalid_beginning of Uchar.t
(* Character not allowed as first char
*)
So iconic: Valid means valid, Invalid_character of Uchar.t means character not allowed, and Invalid_beginning of Uchar.t means character not allowed as first char. The comments stay exactly as they are. π
β validate_identifier β
val validate_identifier : ?with_dot:bool -> t -> validation_result
Like is_valid_identifier, but returns a more detailed error code. Dots can be allowed to extend support to path-like identifiers. So if you're doing path-like stuff, ?with_dot is your girl. π«Ά
π starts_like_a_valid_identifier π
val starts_like_a_valid_identifier : t -> bool
Checks whether the given normalized string starts with an identifier character other than a digit or a single quote. Subsequent characters are not checked. It's giving βjust the beginning, no full auditβ. π
k bye bestie π
this iconic page was brought to you by OCamldoc, date 2026-06-22, for Misc.Utf8_lexeme(3). Mwah. π
π¦ 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