is-cjk-hanzi
v1.0.0
Published
Whether a character is a (single) cjk hanzi
Downloads
92
Maintainers
Readme
is-cjk-hanzi
A handy utility to determine if a character or string contains CJK (Chinese, Japanese, Korean) Hanzi/Kanji characters.
Installation
npm install is-cjk-hanzi
Purpose
Some characters are tricky to work with because they are surrogate pairs and have a length of 2.
console.log('𧓈'.length); // 2
isSingleCJKHanzi('𧓈'); // true
Usage
const isCJKHanzi = require('is-cjk-hanzi');
isCJKHanzi('我'); // true
isCJKHanzi('詠む'); // true
isCJKHanzi('hello'); // false
// Check for single CJK Hanzi characters
const isSingleCJKHanzi = require('is-cjk-hanzi/isSingleCJKHanzi');
isSingleCJKHanzi('我'); // true
isSingleCJKHanzi('我的'); // false
Functions
isCJKHanzi(inputString)
- Returns
true
if the input string contains at least one CJK Hanzi character;false
otherwise.
- Returns
isSingleCJKHanzi(inputCharacter)
- Returns
true
if the input is a single CJK Hanzi character;false
otherwise.
- Returns