2020-03-07 11:45:40 +08:00
|
|
|
/* eslint-disable yoda */
|
2020-03-31 20:40:00 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const isFullwidthCodePoint = codePoint => {
|
|
|
|
if (Number.isNaN(codePoint)) {
|
2020-01-28 13:07:56 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-31 20:40:00 +08:00
|
|
|
// Code points are derived from:
|
2020-01-28 13:07:56 +08:00
|
|
|
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
|
|
|
|
if (
|
2020-03-31 20:40:00 +08:00
|
|
|
codePoint >= 0x1100 && (
|
|
|
|
codePoint <= 0x115F || // Hangul Jamo
|
|
|
|
codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
|
|
|
|
codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
|
2020-01-28 13:07:56 +08:00
|
|
|
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
2020-03-31 20:40:00 +08:00
|
|
|
(0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
2020-03-31 20:40:00 +08:00
|
|
|
(0x3250 <= codePoint && codePoint <= 0x4DBF) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// CJK Unified Ideographs .. Yi Radicals
|
2020-03-31 20:40:00 +08:00
|
|
|
(0x4E00 <= codePoint && codePoint <= 0xA4C6) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// Hangul Jamo Extended-A
|
2020-03-31 20:40:00 +08:00
|
|
|
(0xA960 <= codePoint && codePoint <= 0xA97C) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// Hangul Syllables
|
2020-03-31 20:40:00 +08:00
|
|
|
(0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// CJK Compatibility Ideographs
|
2020-03-31 20:40:00 +08:00
|
|
|
(0xF900 <= codePoint && codePoint <= 0xFAFF) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// Vertical Forms
|
2020-03-31 20:40:00 +08:00
|
|
|
(0xFE10 <= codePoint && codePoint <= 0xFE19) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// CJK Compatibility Forms .. Small Form Variants
|
2020-03-31 20:40:00 +08:00
|
|
|
(0xFE30 <= codePoint && codePoint <= 0xFE6B) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// Halfwidth and Fullwidth Forms
|
2020-03-31 20:40:00 +08:00
|
|
|
(0xFF01 <= codePoint && codePoint <= 0xFF60) ||
|
|
|
|
(0xFFE0 <= codePoint && codePoint <= 0xFFE6) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// Kana Supplement
|
2020-03-31 20:40:00 +08:00
|
|
|
(0x1B000 <= codePoint && codePoint <= 0x1B001) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// Enclosed Ideographic Supplement
|
2020-03-31 20:40:00 +08:00
|
|
|
(0x1F200 <= codePoint && codePoint <= 0x1F251) ||
|
2020-01-28 13:07:56 +08:00
|
|
|
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
2020-03-31 20:40:00 +08:00
|
|
|
(0x20000 <= codePoint && codePoint <= 0x3FFFD)
|
2020-01-28 13:07:56 +08:00
|
|
|
)
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
2020-03-31 20:40:00 +08:00
|
|
|
|
|
|
|
module.exports = isFullwidthCodePoint;
|
|
|
|
module.exports.default = isFullwidthCodePoint;
|