Jump to content

Wikifunctions:Type proposals/Unicode General Category

From Wikifunctions

Summary

An enumeration of the possible values of a Unicode code point (Z86)'s General_Category property, as described at w:Unicode character property#General Category or the Unicode Character Database docs. From the latter: The General_Category values constitute a rough partitioning of characters to make distinctions for algorithmic processing [...]

Uses

These categories are used to segment strings, for example with Regular Expressions \p. They're exposed in every Unicode processing library as they're a core part of the spec.

Structure

A Typed enum of Wikidata references (Z6884).

The grouped values (e.g. \p{N} = (\p{Nd}|\p{Nl}|\p{No})) are provided as a convenience for implementations, such as regex, which may wish to match more generic categories, such as "letter" or "number" and no code point is in those categories directly. So we could exclude them from the enum, forcing users to represent those as sets of values.

Example values

and maybe

Validator

per Typed enum of Wikidata references (Z6884)

Identity

per Typed enum of Wikidata references (Z6884)

Converting to code

per Typed enum of Wikidata references (Z6884)

Display function

Print the 2-letter identifier from the spec.

You could have alternate display functions which give the name of the category (pulling localised labels from Wikidata?) or the QID.

Read function

Accept the 2-letter identifier from the spec. None of the categories start with a 'Q' so it should be safe to accept QIDs as well.

Alternatives

none considered

Comments

For general comments, please reply to the proposer.

  • Support Support as proposer. YoshiRulz (talk) 21:42, 27 July 2025 (UTC)reply
    Along with the grouped categories, Cn is also not used by any character because that data file [UnicodeData.txt] does not list unassigned code points. I think knowing that can help, in a way, with deciding which Items to include: Is this an enum of the categories a character can possibly be in, or is it an enum of all the defined categories? The latter would be more useful, as it is in RegEx. YoshiRulz (talk) 08:39, 11 March 2026 (UTC)reply
Support Support I think that we could create the Wikidata items (I think they should respect the Wikidata criteria for notability, right?). Obviously, being a lighteight Wikidata enumeration, there won't be any reading and display functions. Dv103 (talk) 06:57, 11 September 2025 (UTC)reply