Re:Show HN: u8p – A Go Utility for Precise UTF-8 String Trun...
by lifthrasiir on Saturday May 04, 2024 @08:04PM
(#40261325)
> I was thinking about whether to return an error. If we can’t find a UTF-8 start byte in the nearby 4 bytes, it’s unclear what to return. I thought maybe we could ignore this problem.
This highly depends on the use case, and your stated use case doesn't seem to need any sort of error.
> Also, I want to avoid copying large strings.
Go strings are not copied in that way; they are implemented like immutable slices [1].
This highly depends on the use case, and your stated use case doesn't seem to need any sort of error.
> Also, I want to avoid copying large strings.
Go strings are not copied in that way; they are implemented like immutable slices [1].
[1] https://research.swtch.com/godata