-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lone surrogates #20
Comments
Looks like lone surrogates are typically treated as control characters, which get a break on both sides. These are the Unicode semantics, but I haven't tested with various implementations yet. |
@annevk great question. In general, I will say that 402 is underspecified when it comes to surrogates, only mentioned briefly on collator. @littledan maybe this is a good opportunity to improve that area all together. |
I can't imagine how it could be better specified than those details in UTS29 above. If we weaken the definition of breaks to allow more diversity of conforming implementations, do we want to then go back and specify the behaviour for surrogates? |
I will add it to my list of things to discuss in the next/first 402 meeting :) if we have time. |
If you defer to UTS29 it seems indeed this is defined, but would be good to have tests as they are a bit of an edge case. |
Looking again at the spec, I see that I've merged a patch to no longer reference UTS29, see ad6fa34 . This was done based on a request from Mozilla engineers (which?) to allow this to have line breaking which matched the surrounding platform, where theirs was not based on UTS29. I guess we could be more specific just about lone surrogates, but I don't really see why that's more important than, well, everything else that we're leaving just plain undefined. |
I see, it would be nice to be a little stricter than that or at least figure out what's common, but I guess nobody wants to sign up for that. Seems that the minimum you could require in such a case is that the algorithm in question has an answer for all code points and not just scalar values or some such. |
@annevk I don't understand the details of why Firefox wants to use a different line breaking algorithm (for lower memory usage?) and exactly how they compare. But this is a bigger issue to discuss mostly in CSSWG. I think the current spec basically does say that it should have an answer for all code points. Even in the more general form, it doesn't give the algorithm an opportunity to "error out" on some strings. |
Hmm, so one thing that could be tested is that CSS and this use the same algorithm. |
FWIW I need to fix #17 before that's a valid test. |
cc @bakkot |
We've discussed at a few Intl calls whether we should revert #18 or not. It seems like we're still waiting for more data from Mozilla about whether they would be able to ship this data or not. If we do decide to make normative references to UAX 29 and 14, that answers the question; otherwise, I think we should leave this implementation-dependent. |
If there's still a question here, I think it could be resolved by adding text that just requires consistent successful handling for all input but leaves the specifics of such handling implementation-defined, inside or outside a note and with or without a non-normative reference to UAX #14. |
What's the current status of Mozilla and ICU segmentation? Has anything changed? Cc @jswalden @zbraniecki I don't see why we would reference UAX/UTS 14, as we no longer include line breaking. We could reference UTS 29, if Mozilla is OK with it. |
@jfkthame you should maybe chime in here. |
Is this only about grapheme cluster segmentation, or do we also need to consider the other types of segment breaks described in UTS 29? For grapheme-cluster breaks, UTS 29 is clear there should be a break before and after a lone surrogate, thanks to rule GB999. But for other kinds of segmentation, it looks like UTS 29 no longer fully addresses the issue of lone surrogate code units, as it was updated for Unicode 12 (see the Modifications section) to classify them as XX (unknown). And for word breaks, the behavior of XX is not specified in UTS 29:
It seems appropriate to me that there should be a word break before and after any lone surrogate, but I don't know if there's any spec that explicitly says so at this point. As for Mozilla's implementation: I think we're fine with using UTS 29 for the definition of grapheme cluster boundaries. If our implementation fails to follow its rules, that would simply be a bug that we should fix. I'm unsure about other levels of segmentation: I don't think we currently ship all the ICU code to support word segmentation, and our existing code is unlikely to exactly match it. (It looks quite primitive, actually.) Whether we're ready to add all the ICU segmentation code would be a product-level decision, weighing up the cost (in added download and install size) vs the benefit. |
We'll leave implementations to do the right thing here with respect to boundary determination in any given locale, rather than overconstrain them. |
It doesn't seem so clear to me that GB999 means that. There is no mention of lone surrogates here, and while lone surrogates would fall under Any (as they are in none of the ranges in GraphemeBreakProperty.txt), Any is still unconditionally joined with Prepend, and possibly with SpacingMark, Extend, and ZWJ(!). |
Yes - on looking again now, that appears to be correct. |
How does this API deal with lone surrogates? Are those a valid grapheme cluster?
The text was updated successfully, but these errors were encountered: