[Pitch] Providing access to UCharDirection value in Unicode.Scalar.Properties

Even though Swift provides a number of properties available through the Unicode Consortium's ICU library and CLDR data by way of Unicode.Scalar.Properties, one that is currently not available is the bidi category that, in ICU, can be returned by the C API u_charDirection().

Applications that need this information, such as language tools or line layout libraries, currently must use bridging code to get these values. For some platforms, including Apple platforms, ICU is not easily available to the Swift developer.

One such tool I’ve been developing needs these values. In addition to this low-level BidiCategory, I’ve also made use of a generalized type that I’ve called GeneralBidiClass that groups certain categories together such as U_RIGHT_TO_LEFT and U_RIGHT_TO_LEFT_ARABIC for a general “right-to-left” class. Another grouping includes all of the starting isolate categories (left-to-right, right-to-left, and first-strong).

In 2019, Michael_Ilseman proposed this in Unicode Enthusiasts Unite, and now I’m ready to make it available.

2 Likes

As a point of clarification, the stdlib does not use ICU in any way (for binary size, perf, and dependencies reasons). Nor does it surface any CLDR data. Locale-aware processing and data-heavy processing is pretty firmly outside of the stdlib's mandate.

The properties that the stdlib does expose come from the Unicode Character Database (UAX #44: Unicode Character Database), and that has bidi properties in it. Adding more data from the UCD is possible, given compelling arguments for usefulness relative to cost in binary size.