JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q20589F
  • License MIT

number of bytes used to represent the characters

Package Exports

  • lenb

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lenb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

lenb

lenb returns the number of bytes used to represent the characters in a text string.

Different: string.prototype.length returns the number of characters in a text string.

lenb is the javascript version for lenb in Microsoft Excel.

Install

$ npm install lenb

Usage

const lenb = require('lenb')

lenb('foo')
// => 3

lenb('foobar')
// => 6

lenb('你好')
// => 4

lenb('こんにちは')
// => 10

NOTE: These functions may not be available in all languages.

NOTE: lenb counts 2 bytes per character only when a DBCS language is set as the default language. Otherwise lenb behaves the same as string.prototype.length, counting 1 byte per character.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.