diff options
Diffstat (limited to 'util/japanese.ts')
-rw-r--r-- | util/japanese.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/util/japanese.ts b/util/japanese.ts index d398b60..8381608 100644 --- a/util/japanese.ts +++ b/util/japanese.ts @@ -59,6 +59,9 @@ declare global { */ japaneseOnly(strict?: boolean): boolean + /** @summary check if the string contains kanji characters */ + hasKanji(): boolean; + /** @summary convert any half-width katakana to full-width */ widenKatakana(): string; @@ -270,3 +273,10 @@ String.prototype.normalizeKana = function() { return this.widenKatakana().katakanaToHiragana(); } +String.prototype.hasKanji = function() { + for (var c of this) + if ([UnicodeRange.JapaneseKanji].includes(c.range())) + return true; + return false; +} + |