0.5.0 • Published 12 months ago

japanese-string-utils v0.5.0

Weekly downloads
266
License
MIT
Repository
github
Last release
12 months ago

japanese-string-utils

The utils convert Japanese strings to other forms, such as Hiragana, Katakana, Full-width, Half-width, numeric and others.

日本語テキストをひらがな、カタカナ、全角、半角、数字などへの変換をするためのユーティリティー。

Latest NPM release MIT License

Usage

with NPM

$ npm install --save japanese-string-utils
import {
  toAscii,
  toFullwidth,
  toHiragana,
  toKatakana,
  toFullwidthKana,
  toHalfwidthKana,
  toNfc,
  toNumeric,
  toNumericFromKanji,
  addCommas,
  normalizeHyphens,
} from 'japanese-string-utils';

console.log( toAscii( 'ABCDEFabcdef012345' ) );
// -> 'ABCDEFabcdef012345'

console.log( toFullwidth( 'ABCDEFabcdef012345' ) );
// -> 'ABCDEFabcdef012345'

console.log( toHiragana( 'ジャバすくりぷと' ) );
// -> 'じゃばすくりぷと'

console.log( toKatakana( 'ジャバすくりぷと' ) );
// -> 'ジャバスクリプト'

console.log( toFullwidthKana( 'ジャバスクリプト' ) );
// -> 'ジャバスクリプト'

console.log( toHalfwidthKana( 'ジャバスクリプト' ) );
// -> 'ジャバスクリプト'

console.log( toNFC( 'シ゛ャハ゛スクリフ゜ト' ) );
// -> 'ジャバスクリプト'

console.log( toNumeric( '3.1415' ) );
// -> '3.1415'

console.log( toNumericFromKanji( '百二三億四十万千五六十七' ) );
// -> '12300401567'
console.log( toNumericFromKanji( '1億5600万' ) );
// -> '156000000'

console.log( addCommas( '12345678.90' ) );
// -> '12,345,678.90'

console.log( normalizeHyphens( '-‐‑‒–—―⁃−─━ and some letters' ) );
// -> '‐‐‐‐‐‐‐‐‐‐‐ and some letters'
console.log( normalizeHyphens( '123ー456−789', 'H' ) );
// -> '123H456H789'
0.3.0

12 months ago

0.3.5

12 months ago

0.5.0

12 months ago

0.3.2

12 months ago

0.4.0

12 months ago

0.3.1

12 months ago

0.3.4

12 months ago

0.3.3

12 months ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

7 years ago

0.1.0

7 years ago