aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-07-05 18:23:56 +0200
committerlonkaars <loek@pipeframe.xyz>2023-07-05 18:23:56 +0200
commit4e32a1942ff2478b557af1b900b3f3282d7ce55b (patch)
treedda6cc88d4113d691cf8a16c49f3e13890b9d67d /util
parent5b0b8c82a8477cfe49a538f267805488daa7f5bd (diff)
fix examples/furigana-html.ts
Diffstat (limited to 'util')
-rw-r--r--util/japanese.ts10
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;
+}
+