utf8-byte-length

WebJar for utf8-byte-length

License

License

GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

utf8-byte-length
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

utf8-byte-length
WebJar for utf8-byte-length
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/parshap/utf8-byte-length

Download utf8-byte-length

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/utf8-byte-length/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>utf8-byte-length</artifactId>
    <version>1.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/utf8-byte-length/
implementation 'org.webjars.npm:utf8-byte-length:1.0.4'
// https://jarcasting.com/artifacts/org.webjars.npm/utf8-byte-length/
implementation ("org.webjars.npm:utf8-byte-length:1.0.4")
'org.webjars.npm:utf8-byte-length:jar:1.0.4'
<dependency org="org.webjars.npm" name="utf8-byte-length" rev="1.0.4">
  <artifact name="utf8-byte-length" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='utf8-byte-length', version='1.0.4')
)
libraryDependencies += "org.webjars.npm" % "utf8-byte-length" % "1.0.4"
[org.webjars.npm/utf8-byte-length "1.0.4"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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.

Versions

Version
1.0.4