Functions to convert UTF-8 characters between full-width 全角 and half-width 半角
npm install henkakuFunctions to convert UTF-8 characters between full-width 全角 and half-width 半角.
npm install henkaku
`Usage
toFullWidth(str: string) -> string
` typescript
import { toFullWidth } from "henkaku"const input = "Hello、 ニホン"
const output = toFullWidth(str: string)
console.log(output) // Hello、 ニホン
`
toHalfWidth(str: string) -> string
` typescript
import { toHalfWidth } from "henkaku"const input = "Hello、 ニホン"
const output = toHalfWidth(str: string)
console.log(output) // Hello、 ニホン
`Conversion rules
1. Latins are converted by add/minus
0xFEE0`2. Whitespace is converted between U+0020 (" ") and U+0300 (" ")
3. Katakana is converted by mapping by following UTF8 table (U+FF00..U+FFEF)
\* Note: (Hannkaku katakana with dakuden, e.g ga ガ, is made by two half-width characters, カ and ゙. i.e. U+FF76U+FF9E)
4. For punctuations and symbol, this only convert it to its counterpart. I.e It won't be correcting an English comma or a Japanese comma. It is because there are too many variants in different languages. e.g comma can be (, ,、 ,,, ...). So, I think it is better to do it yourself.