News for hackers. Stuff that matters.
Re:Go 1.18 by morelisp on Wednesday March 16, 2022 @02:35PM (#30702352)
None of your proposals truncate a Unicode string to the first 63 characters. Go and Rust are at least honest about this. Ruby lies about what you're indexing and makes you pay O(n) to do it. (And no, that's not the way you're "supposed to" truncate to a codepoint offset in Go, but it's also true that there's no function to do it in the standard library - in part because that's rarely what you really want to do and it would get abused to do such.)

> When you're handed a string you can generally assume it's been parsed and validated under that character set

But it might not have been. It's a weakass guarantee, the same Go gives you, except in Go it's UTF-8-or-garbage, vs. Ruby's could-be-anything-and-could-still-be-garbage.

There are no comments on this comment yet.