You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Handle the possible surrogate pair (a pair of two UTF-16 code points) at the end properly when you truncate the filename.
Like how the package “truncate-utf8-bytes” does; but note that this package truncates a string to a specific number of bytes, not UTF-16 code points, unlike String.prototype.slice.
And by the way, truncating to a specific number of bytes instead of UTF-16 code points might be more suitable for filenames.
The text was updated successfully, but these errors were encountered:
Note that slice also breaks a Unicode grapheme cluster (e.g. combined family emojis). While disassembled Unicode grapheme clusters are still valid, breaking a surrogate pair, which represents a single code point, renders the string invalid in UTF-8 and UTF-16.
Handle the possible surrogate pair (a pair of two UTF-16 code points) at the end properly when you truncate the filename.
Like how the package “
truncate-utf8-bytes
” does; but note that this package truncates a string to a specific number of bytes, not UTF-16 code points, unlikeString.prototype.slice
.And by the way, truncating to a specific number of bytes instead of UTF-16 code points might be more suitable for filenames.
The text was updated successfully, but these errors were encountered: