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.