项目作者: Xotic750

项目描述 :
Tests if 2 characters together are a surrogate pair.
高级语言: JavaScript
项目地址: git://github.com/Xotic750/is-surrogate-pair-x.git
创建时间: 2015-11-26T00:20:30Z
项目社区:https://github.com/Xotic750/is-surrogate-pair-x

开源协议:Other

下载



Travis status


Dependency status


devDependency status


npm version


jsDelivr hits


bettercodehub score


Coverage Status

is-surrogate-pair-x

Tests if 2 characters together are a surrogate pair.

module.exports(char1, [char2])boolean

Tests if the two character arguments combined are a valid UTF-16
surrogate pair.

Kind: Exported function
Returns: boolean - Returns true if the two characters create a valid
‘UTF-16’ surrogate pair; otherwise false.

Param Type Description
char1 * The character combination, or if char2 is supplied then the first character of a suspected surrogate pair.
[char2] * The second character of a suspected surrogate pair.

Example

  1. import isSurrogatePair from 'is-surrogate-pair-x';
  2. const test1 = 'a';
  3. const test2 = '𠮟';
  4. console.log(isSurrogatePair(test1)); // false
  5. console.log(isSurrogatePair(test1.charAt(0), test1.charAt(1))); // false
  6. console.log(isSurrogatePair(test2)); // true
  7. console.log(isSurrogatePair(test2.charAt(0), test2.charAt(1))); // true