|
|
||
|---|---|---|
| .. | ||
| bin | ||
| docs | ||
| etc | ||
| lib | ||
| package.json | ||
| README.md | ||
hasUTF16SurrogatePairAt
Test if a position in a string marks the start of a UTF-16 surrogate pair.
Usage
var hasUTF16SurrogatePairAt = require( '@stdlib/assert/has-utf16-surrogate-pair-at' );
hasUTF16SurrogatePairAt( string, position )
Tests if a position (in UTF-16 code units) in a string marks the start of a UTF-16 surrogate pair.
var bool = hasUTF16SurrogatePairAt( '🌷', 0 );
// returns true
bool = hasUTF16SurrogatePairAt( '🌷', 1 );
// returns false
Notes
- Note that
positiondoes not refer to a visual character position, but to an index in the ordered sequence of UTF-16 code units.
Examples
var hasUTF16SurrogatePairAt = require( '@stdlib/assert/has-utf16-surrogate-pair-at' );
var bool = hasUTF16SurrogatePairAt( '🌷', 0 );
// returns true
bool = hasUTF16SurrogatePairAt( '🌷', 1 );
// returns false
CLI
Usage
Usage: has-utf16-surrogate-pair-at [options] [<string>] --pos=<index>
Options:
-h, --help Print this message.
-V, --version Print the package version.
--pos index Position in string.
Examples
$ has-utf16-surrogate-pair-at --pos=0 🌷
true
To use as a standard stream,
$ echo -n '🌷' | has-utf16-surrogate-pair-at --pos=1
false