TLDR Web Dev · ARTICLES & TUTORIALS
JAVASCRIPT STRING SLICE() CONSIDERED HARMFUL
Summary from the TLDR Web Dev newsletter
A bug was discovered in Attio's CSV importer when using JavaScript's `slice()` method to truncate strings. It was causing gRPC errors when it split Unicode characters (like flag emojis) in the middle of their UTF-16 code units, resulting in invalid data being sent to their database. The issue occurs because `slice()` operates on code units rather than complete Unicode code points, so truncating "🇬🇧" could result in incomplete character data like "🇬\uD83C".