Skip to content

Conversation

@lorentey
Copy link
Member

@lorentey lorentey commented Jan 5, 2023

Cherry-picked from #62794.

Unicode._CharacterRecognizer is a newly exported opaque type that exposes the stdlib’s extended grapheme cluster breaking facility, independent of String.

This essentially makes the underlying simple state machine public, without exposing any of the (unstable) Unicode details.

The ability to perform grapheme breaking over, say, the scalars stored in multiple String values can be extremely useful while building custom text processing algorithms and data structures.

Ideally this would eventually become API, but before proposing this to Swift Evolution, I’d like to prove the shape of the type in actual use (and we’ll also need to find better names for its operations).

rdar://103903565

Instead of just checking the number of breaks in each test case,
expose and check the actual positions of those breaks, too.
This turns _GraphemeBreakingState into a more proper state
machine, although it is only able to recognize breaks in the
forward direction.

The backward direction requires arbitrarily long lookback,
and it currently remains in _StringGuts.
`Unicode._CharacterRecognizer` is a newly exported opaque type that
exposes the stdlib’s extended grapheme cluster breaking facility,
independent of `String`.

This essentially makes the underlying simple state machine public,
without exposing any of the (unstable) Unicode details.

The ability to perform grapheme breaking over, say, the scalars stored
in multiple `String` values can be extremely useful while building
custom text processing algorithms and data structures.

Ideally this would eventually become API, but before proposing this
to Swift Evolution, I’d like to prove the shape of the type in actual
use (and we’ll also need to find better names for its operations).
@lorentey lorentey added the r5.8 label Jan 5, 2023
@lorentey
Copy link
Member Author

lorentey commented Jan 5, 2023

@swift-ci test

@lorentey
Copy link
Member Author

lorentey commented Jan 5, 2023

Test Case 'SwiftDriverTests.testToolSearching' started at 2023-01-05 09:48:19.625
<EXPR>:0: error: SwiftDriverTests.testToolSearching : threw error "failed to retrieve frontend target info"
Test Case 'SwiftDriverTests.testToolSearching' failed (0.003 seconds)

@lorentey
Copy link
Member Author

lorentey commented Jan 5, 2023

@swift-ci test linux platform

@lorentey lorentey requested review from Azoy and stephentyrone January 5, 2023 21:10
@lorentey lorentey merged commit 7c59254 into swiftlang:release/5.8 Jan 6, 2023
@lorentey lorentey deleted the character-recognizer-5.8 branch January 6, 2023 00:03
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.8 labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 release cherry pick Flag: Release branch cherry picks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants