Return the number of Unicode code points in a string.
var numCodePoints = require( '@stdlib/string/num-code-points' );
Returns the number of code points in a string.
var out = numCodePoints( 'last man standing' );
// returns 17
out = numCodePoints( 'Hidden Treasures' );
// returns 16
out = numCodePoints( '👋👋👋' );
// returns 3
var numCodePoints = require( '@stdlib/string/num-code-points' );
console.log( numCodePoints( 'last man standing' ) );
// => 17
console.log( numCodePoints( '六书/六書' ) );
// => 5
console.log( numCodePoints( '🐶🐮🐷🐰🐸' ) );
// => 5
console.log( numCodePoints( 'Hello 👋 World' ) );
// => 13
Usage: num-code-points [options] [<string>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
-l, --lines Analyze individual lines.
$ num-code-points beep
4
To use as a standard stream,
$ echo -n 'beep\nboop書' | num-code-points
10
$ echo -n 'beep\nboop書' | num-code-points -l
4
5