Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing unicode categories in python library #3872

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joprice
Copy link
Contributor

@joprice joprice commented Jul 23, 2024

This adds the missing unicode categories to fix the error ValueError: Fable error, unknown Unicode category: Ps when calling for example, Char.IsLetterOrDigit with left paren '('.

I used the values defined in the referenced doc https://docs.microsoft.com/en-us/dotnet/api/system.globalization.unicodecategory?view=net-6.0, and also found that No was assigned to UnicodeCategory.OtherLetter instead of UnicodeCategory.OtherNumber.

I'm not sure how to test the surrogate category, as I hit an error I left a note about that I didn't get a chance to look into.

The test data was created by running the following script

import sys
import unicodedata
from collections import defaultdict

unicode_category = defaultdict(list)
for c in map(chr, range(sys.maxunicode + 1)):
    unicode_category[unicodedata.category(c)].append(c)

for value in unicode_category.values():
    c = value[0]
    e = c.encode("unicode_escape")
    print(repr(e), unicodedata.category(c))

which groups chars by category and then prints each category with a sample value.

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.

1 participant