titlecase(::String) should not break words inside graphemes #38575
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in #38574 (comment), at the very least we should not consider characters in the middle of graphemes to be word separators — this PR fixes
titlecase(::String)
to givetitlecase("bôrked") == "Bôrked"
instead of"BôRked"
.Also, the documentation said that the default word separator is any "non-letter" character, but actually it was
!iscased
. I see no reason to not actually use!isletter
here.In the future, it would be better to follow the Unicode standard for word boundaries, and ideally have a "word" iterator much like our current grapheme iterator, but this requires support from utf8proc (JuliaStrings/utf8proc#208). But the behavior in this PR is at least closer to the standard.
This is technically not backward compatible, but I think it is unlikely to be a problem — the old behavior seems more like a bug to me.
cc @rfourquet, who last touched this function in #23393.