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

Improve VerseRef.TrySetVerseUnicode by handling non-decimal numerals and surrogate pair numerals. #1000

Closed
SamDelaney opened this issue Nov 25, 2020 · 1 comment

Comments

@SamDelaney
Copy link
Contributor

This change would allow applications to more easily and broadly use vernacular versification.

The methods char.IsDigit and char.GetNumericValue (used in VerseRef.TryGetVerseNum) only handle base-10, non-surrogate numerals (Complete list here). A broader alternative to these methods would have to be found or made.

The value calculation in TrySetVerseUnicode also currently assumes a decimal base:
vNum = (short)(vNum * 10 + (romanOnly ? ch - '0' : char.GetNumericValue(ch)));
This would have to be changed.

See discussion on #999 for additional context and (ignored) test cases.

@ermshiperete
Copy link
Member

.NET 5 (and .NET Core 3+) has Rune.IsDigit and Rune.GetNumericValue methods that can deal with surrogate pairs.

Alternatively this could be implemented with Char.IsDigit/Char.IsNumber and Char.IsSurrogate to identify the first part of the string that represents the number and Int32.TryParse to convert the first part of the string to a number.

elisunger added a commit to elisunger/libpalaso that referenced this issue Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants