Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 1 | /* eslint-disable yoda */ |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 2 | 'use strict'; |
| 3 | |
| 4 | const isFullwidthCodePoint = codePoint => { |
| 5 | if (Number.isNaN(codePoint)) { |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 6 | return false; |
| 7 | } |
| 8 | |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 9 | // Code points are derived from: |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 10 | // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt |
| 11 | if ( |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 12 | codePoint >= 0x1100 && ( |
| 13 | codePoint <= 0x115F || // Hangul Jamo |
| 14 | codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET |
| 15 | codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 16 | // CJK Radicals Supplement .. Enclosed CJK Letters and Months |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 17 | (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 18 | // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 19 | (0x3250 <= codePoint && codePoint <= 0x4DBF) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 20 | // CJK Unified Ideographs .. Yi Radicals |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 21 | (0x4E00 <= codePoint && codePoint <= 0xA4C6) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 22 | // Hangul Jamo Extended-A |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 23 | (0xA960 <= codePoint && codePoint <= 0xA97C) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 24 | // Hangul Syllables |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 25 | (0xAC00 <= codePoint && codePoint <= 0xD7A3) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 26 | // CJK Compatibility Ideographs |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 27 | (0xF900 <= codePoint && codePoint <= 0xFAFF) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 28 | // Vertical Forms |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 29 | (0xFE10 <= codePoint && codePoint <= 0xFE19) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 30 | // CJK Compatibility Forms .. Small Form Variants |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 31 | (0xFE30 <= codePoint && codePoint <= 0xFE6B) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 32 | // Halfwidth and Fullwidth Forms |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 33 | (0xFF01 <= codePoint && codePoint <= 0xFF60) || |
| 34 | (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 35 | // Kana Supplement |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 36 | (0x1B000 <= codePoint && codePoint <= 0x1B001) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 37 | // Enclosed Ideographic Supplement |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 38 | (0x1F200 <= codePoint && codePoint <= 0x1F251) || |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 39 | // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 40 | (0x20000 <= codePoint && codePoint <= 0x3FFFD) |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 41 | ) |
| 42 | ) { |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | return false; |
| 47 | }; |
Tim van der Lippe | d3425b9 | 2022-01-07 14:05:09 +0100 | [diff] [blame] | 48 | |
| 49 | module.exports = isFullwidthCodePoint; |
| 50 | module.exports.default = isFullwidthCodePoint; |