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
strings: Split is inconsistent with bytes.Split #53511
Comments
Change https://go.dev/cl/413715 mentions this issue: |
https://go.dev/play/p/7PPxD1AyxTq shows it together with 2 other situations where utf8 rune splitting is being done that are handled differently again. To me it looks like the strings and bytes package are both being inconsistent to each of the other documented rune splitting methods and probably both need to be adjusted. Or maybe I am missing something here and those functions are supposed to support rune splitting in a different way in order to allow for edge cases I am not aware of. |
@nightlyone. My CL makes it such that your example prints:
This brings the Regarding the last two lines in your example, there is no documented guarantee that |
Consider the following:
The results of these two are inconsistent where the
strings
implementation replaced\xff
withutf8.RuneError
, even though the documentation ofstrings.Split
mentions no such behavior. It only says that it slices up the input.
Furthermore, it is odd, that it only mangles the first element of the result, but not the last.
The text was updated successfully, but these errors were encountered: