Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more
Module

x/libauth/src/lib/format/utf8.ts>length

An ultra-lightweight, zero-dependency JavaScript library for Bitcoin Cash, Bitcoin, and Bitauth applications.
Latest
variable length
import { length } from "https://deno.land/x/libauth@v2.0.0-alpha.9/src/lib/format/utf8.ts";

Return the user-perceived character length of the given string, e.g.:

const test = 'fitπŸš€πŸ‘«πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦'
console.log(test.length); // 17
console.log(length(test)); // 5

Note, this utility segments the string into grapheme clusters using Intl.Segmenter, a TC39 proposal which reached stage 4 in 2022, and may not be supported in older environments.

type

(utf8: string) => unknown