You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're dealing with ASCII, truncating to bytes is trivial.
If you're trying to limit columns of output to display to a user, you probably need to take into account character widths and also truncate to a grapheme cluster boundary, not just a rune boundary.
So this seems like too much complexity for the ASCII case, and not nearly enough for the full Unicode case... what problems does that leave for it to solve?
Reacted by Ben Hoyt, Artyom Pervukhin, Hunter Herman, Konstantin, Mark Pulford and Tang Liang
This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group
If you're trying to limit columns of output to display to a user, you probably need to take into account character widths and also truncate to a grapheme cluster boundary, not just a rune boundary.
FWIW when I want this functionality, it's usually because I want to limit the overall size in memory of something without producing malformed UTF-8. It's true that I might produce a malformed grapheme cluster, but I'd still submit that it's better to do that than splitting at an arbitrary byte.
Similar to the discussion in #53120, this API seems to promise something but really doesn't promise much of anything. It is easy enough to write in a third-party library. It doesn't seem like we should have it here.
Activity
bcmills commentedon Nov 21, 2022
Why runes?
If you're dealing with ASCII, truncating to bytes is trivial.
If you're trying to limit columns of output to display to a user, you probably need to take into account character widths and also truncate to a grapheme cluster boundary, not just a rune boundary.
So this seems like too much complexity for the ASCII case, and not nearly enough for the full Unicode case... what problems does that leave for it to solve?
icholy commentedon Nov 22, 2022
That is a valid criticism, I'm mainly using it for ASCII text.
rsc commentedon Nov 30, 2022
This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group
rogpeppe commentedon Dec 2, 2022
FWIW when I want this functionality, it's usually because I want to limit the overall size in memory of something without producing malformed UTF-8. It's true that I might produce a malformed grapheme cluster, but I'd still submit that it's better to do that than splitting at an arbitrary byte.
I'm not even sure that it's possible to split on grapheme clusters without going outside the standard library
I have a strong recollection of having this discussion before, but I can't for the life of me find the discussion (ISTR that @rsc was involved).
icholy commentedon Dec 3, 2022
@rogpeppe I believe you're thinking about the discussion here #53120
rsc commentedon Dec 7, 2022
Similar to the discussion in #53120, this API seems to promise something but really doesn't promise much of anything. It is easy enough to write in a third-party library. It doesn't seem like we should have it here.
rsc commentedon Dec 14, 2022
Based on the discussion above, this proposal seems like a likely decline.
— rsc for the proposal review group
rsc commentedon Dec 21, 2022
No change in consensus, so declined.
— rsc for the proposal review group