# SE-0559: Add \`bidiClass\` to \`Unicode.Scalar.Properties\`

**URL:** <https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186>\
**Category:** Proposal Reviews\
**Created:** [October 21, 2026, 4:19pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186 "2026-10-21T16:19:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [October 21, 2026, 4:19pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/1 "2026-10-21T16:19:48Z")

</div>

Hello, Swift community!

The review of [SE-0559: Add `bidiClass` to `Unicode.Scalar.Properties`](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0559-unicode-bidi-class.md) begins now and runs through November 4, 2026.

Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to me as the review manager by [email](mailto:dgregor@apple.com) or [DM](https://forums.swift.org/u/Douglas_Gregor/summary). When contacting the review manager directly, please put "SE-0559" in the subject line.

##### **What goes into a review?**

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:

- What is your evaluation of the proposal?
- Is the problem being addressed significant enough to warrant a change to Swift?
- Does this proposal fit well with the feel and direction of Swift?
- If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

More information about the Swift evolution process is available at:

> [swift-evolution/process.md at main · swiftlang/swift-evolution · GitHub](https://github.com/swiftlang/swift-evolution/blob/main/process.md)

Thank you,

Doug Gregor  
Review Manager

---

<div class="post-metadata">

**Author:** ![grynspan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/grynspan/32/15315_2.png) [@grynspan](https://forums.swift.org/u/grynspan)\
**Post date:** [October 21, 2026, 4:42pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/2 "2026-10-21T16:42:26Z")

</div>

Makes sense to me. I'll bikeshed `bidirectionalCharacterClass` or some such since "bidi", while a Unicode term of art, is maybe not widely known outside us grapheme cluster aficionados. But I don't feel strongly, and I see obvious use cases for the property, so 🚢.

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [October 21, 2026, 5:56pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/3 "2026-10-21T17:56:47Z")

</div>

> [@](#):
>
> `Unicode.GeneralCategory` is an enum, and `Unicode.BidiClass` could be one too. A `@frozen` enum would have the same compact layout, but it could never gain cases, so a future `Bidi_Class` value could not be added. That has happened before: Unicode 6.3 added the four isolate classes. A non-`@frozen` enum could gain cases, but its layout would be resilient, so code outside the standard library would handle it indirectly rather than as a single byte.
> 
> A frozen struct with static members gets both a fixed one-byte layout and room for new values, and values this API does not yet name remain representable via `init(rawValue:)`. The tradeoff is that a `switch` over a `Unicode.BidiClass` always needs a `default` case, and the compiler does not flag that `switch` when new values are added.

Unless I'm mistaken, the proposal here is choosing to expose `rawValue` publicly. There's a tradeoff for that (in that it's not meaningful) but an understandable choice.

But, given that choice, I _believe_ a ~~`@c`~~ `@objc` enum that uses `UInt8` raw values would satisfy all of these problems. Has that been explored? The type would be nonfrozen but occupy a single byte, be passed and returned directly across library evolution boundaries, support nesting inside the `Unicode` namespace, and work without Obj-C interop.

---

<div class="post-metadata">

**Author:** ![aviva](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aviva/32/44327_2.png) [@aviva](https://forums.swift.org/u/aviva)\
**Post date:** [October 21, 2026, 6:08pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/4 "2026-10-21T18:08:35Z")

</div>

+1

Will these be removable by the linker for builds on platforms where you statically link all your Swift libraries? EG will this increase the size of "hello world" on android?

And is there any hope of getting East Asian Width tables? I'd like to use it in swift-syntax to handle non latin scripts more correctly (right now we pretend nothing is wide), but I'm aware there is more complexity with this table, and we could codegen efficient tables for that use anyway.

---

<div class="post-metadata">

**Author:** ![niktishakov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/niktishakov/32/47115_2.png) [@niktishakov](https://forums.swift.org/u/niktishakov)\
**Post date:** [October 22, 2026, 4:15am UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/5 "2026-10-22T04:15:25Z")

</div>

+1. Foundation runs into the same problem with other scalar properties. `.caseInsensitive` and `.diacriticInsensitive` need case folding and canonical decomposition, and in package builds on Darwin the `_Unicode` SPI that provides them isn't visible. So [Support case, diacritic and width options outside the framework by niktishakov · Pull Request #2349 · swiftlang/swift-foundation · GitHub](https://github.com/swiftlang/swift-foundation/pull/2349) adds its own tables (about 7 KB), with a TODO pointing to [Add all of the Unicode properties · Issue #58697 · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/issues/58697). Public APIs for those properties, like `bidiClass` here, would let Foundation drop them.

---

<div class="post-metadata">

**Author:** ![benrimmington](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/benrimmington/32/695_2.png) [@benrimmington](https://forums.swift.org/u/benrimmington)\
**Post date:** [October 22, 2026, 11:48am UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/6 "2026-10-22T11:48:58Z")

</div>

> Like `Unicode.CanonicalCombiningClass`, `Unicode.BidiClass` is a `RawRepresentable` struct with a `UInt8` raw value and one static member per `Bidi_Class` value.

I think the raw integer values of `Unicode.BidiClass` should be private or internal, because they aren't defined by the Unicode Standard.

Alternatively, the raw values could be the short identifiers ("L", "R", "AL", "NSM", etc.) This would be similar to the design of [`Foundation::Locale.Script`](https://developer.apple.com/documentation/foundation/locale/script) and [`Foundation::Locale.Region`](https://developer.apple.com/documentation/foundation/locale/region-swift.struct) — which also have conformances to `Codable`, `CustomDebugStringConvertible`, and `ExpressibleByStringLiteral`. (Would `CaseIterable` be useful?)

```swift
import Foundation

print(Foundation::Locale.Script.unknown) // prints "Zzzz"
print(Foundation::Locale.Region.unknown) // prints "ZZ"

```

---

<div class="post-metadata">

**Author:** ![Michael\_Ilseman](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/michael_ilseman/32/44640_2.png) [@Michael\_Ilseman](https://forums.swift.org/u/Michael_Ilseman)\
**Post date:** [November 3, 2026, 8:29pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/7 "2026-11-03T20:29:16Z")

</div>

> [@grynspan](#):
>
> I'll bikeshed `bidirectionalCharacterClass`

I think that's a perfectly reasonable alternative name.

> [@xwu](#):
>
> Unless I'm mistaken, the proposal here is choosing to expose `rawValue` publicly. There's a tradeoff for that (in that it's not meaningful) but an understandable choice.

It's needed for the `RawRepresentable` conformance. We don't have anything to match in-memory representations with, so it's not adding as much signaling value to this type as for other types that follow this pattern. But, given that it's frozen, I don't feel that we should go out of our way to hide the raw value.

> [@xwu](#):
>
> But, given that choice, I _believe_ a ~~`@c`~~ `@objc` enum that uses `UInt8` raw values would satisfy all of these problems. Has that been explored? The type would be nonfrozen but occupy a single byte, be passed and returned directly across library evolution boundaries, support nesting inside the `Unicode` namespace, and work without Obj-C interop.

It would land us in a similar position. From an aesthetic perspective, it feels a little off as this has nothing to do with Objective-C. Practically speaking, I think it would add a synthesized trapping default case in switches with no explicit default. I'm not sure whether that's valuable or not.

Understanding what effect these annotations have in practice ends up being a small research project every time. Whatever the behavior actually is, `@objc` communicates our intent less directly than `@frozen`. I am open to it, but would like some more guidance from the LSG on using these attributes for "off label" purposes.

---

<div class="post-metadata">

**Author:** ![scanon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/scanon/32/2445_2.png) [@scanon](https://forums.swift.org/u/scanon)\
**Post date:** [November 4, 2026, 3:21pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/9 "2026-11-04T15:21:03Z")

</div>

It is unfortunate that `@c` has the wrong semantics, but `@objc` does exactly what we want representationally, gets us better diagnostics for situations like duplicated values, and reduces the need for optimizer heroics in switch statements.

Even though this is an "off-label" use, `@objc` is no more misleading than using `struct` when we are clearly dealing with something that is conceptually an enum. We should use `@objc` here.

---

<div class="post-metadata">

**Author:** ![Karl](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@Karl](https://forums.swift.org/u/Karl)\
**Post date:** [November 17, 2026, 5:24pm UTC](https://forums.swift.org/t/se-0559-add-bidiclass-to-unicode-scalar-properties/90186/10 "2026-11-17T17:24:03Z")

</div>

> [@benrimmington](#):
>
> I think the raw integer values of `Unicode.BidiClass` should be private or internal, because they aren't defined by the Unicode Standard.

+1 to this. I don't think Swift should add another encoding of these values, but the short names are potentially useful (e.g. this is how they would be encoded in a Regex, so if you were going to transmit them to another system for some reason or encode them in a JSON file, that's a good value to use).

Other than that:

- I think `bidiClass` is the correct name for this property.  
Everybody who knows what to do with this data will look for it under the term "bidi class", and it isn't really something anyone can just pick up and use without prior knowledge of what it means. If you do wish to learn more about how to use it, that is also the best term to search for, since the official Unicode property name is "bidi\_class".

- I think `Joining_Type` should be added as well. It's useful for the same kinds of things.

- On the implementation side, one of the main ways to optimise Unicode algorithms is to reduce the number of table lookups. It would be nice if the standard library's lookups for Bidi-related properties came from a single mergeable lookup call - so that if I check for a scalar's bidiClass and joiningType, it could potentially be merged in to a single lookup.
