Reference · Look words up by reading, written form, English meaning, kanji or romaji
normalizeTextfunction
A text made plain for a lookup: composed and compatibility forms folded together (NFKC, so full-width letters and digits become
half-width and half-width kana full-width), whitespace collapsed to single spaces and trimmed, spaces beside Japanese removed,
invisible and control characters removed, and a dash between kana, or ending kana, made the long vowel mark ー. Kana are not folded: that is
foldKana's. Anything that is not a string, and a text longer than a word can be, gives an empty text.
Import it
import { normalizeText } from "@johnmorrisdotca/jisho/words";
Definition
function normalizeText(text: string): string
Parameters
| Name | Type | Description |
|---|---|---|
text | string | Anything a person typed or pasted. |
Returns
string
The plain text; empty when there is nothing to look up.
Examples
import { normalizeText } from "@johnmorrisdotca/jisho/words";
console.log(normalizeText(" カミ\u200B ")); // カミ
console.log(normalizeText("コーヒ-")); // コーヒーカミ
コーヒーWhat it prints (run when this page was built)