Skip to content

Support Uchar.t as testable#435

Open
emengd wants to merge 1 commit intomirage:mainfrom
emengd:uchar
Open

Support Uchar.t as testable#435
emengd wants to merge 1 commit intomirage:mainfrom
emengd:uchar

Conversation

@emengd
Copy link
Copy Markdown

@emengd emengd commented Mar 17, 2026

Hi, I propose this tiny addition of a testable for Uchar.t values.

There is a non-obvious question of how to print such values. Currently the stdlib has neither a formatter for uchars nor a literal syntax to read them back (see upstream discussion here), so it is not possible to provide a directly useable value. I am reusing Fmt.Dump.uchar which does Fmt.pf ppf "U+%04X" (Uchar.to_int uc), for instance "é" becomes U+00E9. To read it back (for instance in the toplevel) you need to write Uchar.of_int 0x00E9.

Some options:

  1. Enclose it in quotes to make it clear it's one value
  2. Use the syntax used in string literals, e.g. "\u{00E9}" (this is a valid string value)
  3. Special case ASCII and print it using %C

But I'm not convinced by any of these, if you're using uchar's you're probably doing something fairly technical and a pure code is good enough for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants