Giter Site home page Giter Site logo

japanese-string-utils's Introduction

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'

japanese-string-utils's People

Contributors

yomotsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

japanese-string-utils's Issues

Add tests

I'd like to add tests described cases on README.md. 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.