LarpixClient/electron/node_modules/utf8-byte-length
olcxja cca8b02fea
Some checks failed
Android Build / publish (push) Successful in 33s
Linux Build / publish (push) Failing after 25s
Update gitignore (sorry)
2026-05-10 14:02:17 +02:00
..
.gitmodules Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
.travis.yml Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
AUTHORS Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
browser.js Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
index.js Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
LICENSE.MIT.txt Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
LICENSE.WTFPL.txt Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
package.json Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
README.md Update gitignore (sorry) 2026-05-10 14:02:17 +02:00
test.js Update gitignore (sorry) 2026-05-10 14:02:17 +02:00

utf8-byte-length build status

Get the utf8 byte length of a string, taking into account multi-byte characters and surrogate pairs.

By default, this module defers to Buffer.byteLength. A browser implementation is also provided that doesn't use Buffer.byteLength minimize build size.

Example

var getLength = require("utf8-byte-length")
console.log(truncate("a☃", 2)) // a = 1 byte, ☃ = 3 bytes
// -> 4

API

var getLength = require("utf8-byte-length")

When using browserify or webpack, this automatically resolves to an implementation that does not use Buffer.byteLength.

getLength(string)

Returns the byte length of string. Throws an error if string is not a string.