5 ms·
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 se
by aidenn0 2y 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.
- adam-p 2y agoI 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-units 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-points https://adam-p.ca/blog/2025/04/string-length/#unicode-code-p...
- adam-p 2y agoI 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-when-the-limit-is-hit https://adam-p.ca/blog/2025/04/string-length/#what-to-do-whe...
- aidenn0 2y agoThanks!