UNPKG

normalize-cjk

Version:

[![Package Version](https://img.shields.io/npm/v/normalize-cjk)](https://npm.im/normalize-cjk) [![License](https://img.shields.io/npm/l/normalize-cjk)](#License) [![NPM Bundle Size](https://img.shields.io/bundlephobia/minzip/normalize-cjk)](https://bundle

23 lines (21 loc) 586 B
/** * Normalize Katakana characters * * Replace all half-width kana with full-width form */ export const normalizeKatakana = (input: string): string => { return input .replace( /[\uff60-\uff9f]+/g, substr => substr.normalize('NFKC'), ); }; /** * Normalize Japanese characters (Katakana) * * Hiragana doesn't seem to need normalization. But it can be added eventually. * * Credits to [Yusuke Nemoto](https://github.com/kaakaa) * @See https://twitter.com/kaakaa_hoe_prog/status/1415149003293954060 */ export const normalizeJapanese = normalizeKatakana;