1.0.3 • Published 6 years ago

num2chn v1.0.3

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Convert Arabic numbers into Chinese.

How To

  1. Require the module, it will return a function.

    //it returns a function, this function can't be directly put in use.
    var num2chn = require('num2chn')
  2. The returned function accepts one parameter, when set to true, it will convert the number into capitalized form(大写数字).

    var num2chnCapt = num2chn(true/*should it be capitalized?*/)
    
    //'壹仟贰佰叁拾'
    num2chnCapt(1230)
  1. When set to false, the returned function will convert the number into normal form.

    var num2chnNormal = num2chn(false)
    
    //'八万零四百五十四'
    num2chnNormal(80454)
  2. When set to 'currency', the returned function will convert the number into currency form.

    var num2Currency = num2chn('currency')
    
    //'壹佰贰拾叁萬元伍角陆分'
    num2Currency(1230000.5645)
  3. Or you can simplly omit the parameter, the number will also be converted into normal form.

    var num2chn = require('num2chn')()//OK
    
    //'八万零四百五十四'
    num2chn(80454)

Notes

  1. Support up to 16-digit number.
  2. Decimals only supported in the currency form, in other forms, the decimal part will be ignored.
  3. Do not support negative numbers. the negative sign(-) will be ignored.