Hacker News new | ask | show | jobs
by aidenn0 411 days ago
This doesn't seem to cover truncation, but rather acceptance/rejection. If you are given something with "too many" codepoints, but need to use it anyways it seems like it would make sense to truncate it on a grapheme cluster boundary.
2 comments

I don't get into truncation much, but I do mention the risk of:

a) failing to truncate on a code point sequence boundary (a bug React Native iOS used to have)[1], and

b) failing to truncate on a grapheme cluster boundary (a bug React Native Android seems to still have)[2]

[1]: https://adam-p.ca/blog/2025/04/string-length/#utf-16-code-un...

[2]: https://adam-p.ca/blog/2025/04/string-length/#unicode-code-p...

I added a section with brief discussion of rejection, truncation, and the perils therein.

https://adam-p.ca/blog/2025/04/string-length/#what-to-do-whe...

Thanks!