-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Expose System.Globalization.CharUnicodeInfo.GetBidiCategory #44464
Comments
Tagging subscribers to this area: @tarekgh, @safern, @krwq Issue meta data
|
FWIW, .NET Framework has the internal BidiCategory enum, while .NET Core / .NET 5 has the internal StrongBidiCategory enum. The runtime does not carry full UCD bidi information; we only carry enough information to make our own use cases (mainly some System.Uri functionality) work correctly. Carrying full bidi information would require reworking the internal |
Background and Motivation
Currently, there is no public API for determining whether a Unicode character is strongly right-to-left, strongly left-to-right or neutral. Such an API can be useful when displaying text in right-to-left and left-to-right languages simultaneously.
Proposed API
StrongBidiCategory.cs
CharUnicodeInfo.cs
Usage Examples
For example, this API can be used to determine the direction to which a block of text should be aligned, based on the first character that is strongly RTL or strongly LTR:
Alternative Designs
The above proposed API was designed to match the existing public overloads of GetUnicodeCategory. Another welcome addition would be overloads accepting
ReadOnlySpan<char>
for each of the methods acceptingstring s, int index
.In .NET Framework, there is a similar internal function with the same name, but it returns
BidiCategory
, an enum that represents the actual BIDI category rather that just the "strong" one. For some use-cases, it may be beneficial to get the more detailed information rather than just a simplified version of it. Therefore, the alternative option would be to instead add new APIs that returnBidiCategory
, plus an extension method that convertsBidiCategory
toStrongBidiCategory
.Risks
Since the proposed API already exists internally, there should no risks for development on newer platforms such as .NET 5. Implementing the alternative design using
BidiCategory
rather thanStrongBidiCategory
may require naming changes and therefore changes to any code which calls the internal APIs.The text was updated successfully, but these errors were encountered: