Skip to content

fix(ios): classify RN writing direction beyond the BMP - #975

Merged
maksg merged 1 commit into
mainfrom
rn-direction-classifier
Oct 26, 2026
Merged

maksg merged 1 commit into
mainfrom
rn-direction-classifier

Conversation

@maksg

@maksg maksg commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #907 for the React Native package. ENRMFirstStrongDirection scanned UTF-16 units against letterCharacterSet and three BMP ranges, so a letter beyond the BMP (Adlam, Old Hungarian) never counted, a leading U+200F, U+200E or U+061C was ignored, and a combining mark counted as a letter.

The scan now decodes surrogate pairs to a scalar, returns LTR for U+200E and RTL for U+200F and U+061C, skips marks, and classifies letters with the two Plane 1 right-to-left ranges added to the table. The predefined character sets are looked up once in the file's constructor. Unlike the Swift resolver, an astral combining mark is skipped rather than classified.

Adds the first XCTest suite under tests/ios, mirroring the Swift WritingDirectionTests cases.

What/Why?

Testing

Screenshots

Before After
Screenshot iPhone 18 Pro Max 11-10-2026 at 12 28 15 Screenshot iPhone 18 Pro Max 11-10-2026 at 12 27 18
Screenshot iPhone 18 Pro Max 11-10-2026 at 12 28 21 Screenshot iPhone 18 Pro Max 11-10-2026 at 12 27 24

PR Checklist

  • Code compiles and runs on iOS
  • Code compiles and runs on Android
  • Updated documentation/README if applicable
  • Ran example app to verify changes
  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Follow-up to #907 for the React Native package. ENRMFirstStrongDirection
scanned UTF-16 units against letterCharacterSet and three BMP ranges, so a
letter beyond the BMP (Adlam, Old Hungarian) never counted, a leading
U+200F, U+200E or U+061C was ignored, and a combining mark counted as a
letter.

The scan now decodes surrogate pairs to a scalar, returns LTR for U+200E
and RTL for U+200F and U+061C, skips marks, and classifies letters with
the two Plane 1 right-to-left ranges added to the table. The predefined
character sets are looked up once in the file's constructor. Unlike the
Swift resolver, an astral combining mark is skipped rather than
classified.

Adds the first XCTest suite under __tests__/ios, mirroring the Swift
WritingDirectionTests cases.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@maksg
maksg merged commit 1daf7aa into main Oct 26, 2026
14 checks passed
@maksg
maksg deleted the rn-direction-classifier branch October 26, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants