num2chn
v1.0.3
Published
Convert A Number to Chinese.
Downloads
6
Maintainers
Readme
Convert Arabic numbers into Chinese.
How To
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')
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)
When set to
false
, the returned function will convert the number into normal form.var num2chnNormal = num2chn(false) //'八万零四百五十四' num2chnNormal(80454)
When set to
'currency'
, the returned function will convert the number into currency form.var num2Currency = num2chn('currency') //'壹佰贰拾叁萬元伍角陆分' num2Currency(1230000.5645)
Or you can simplly omit the parameter, the number will also be converted into normal form.
var num2chn = require('num2chn')()//OK //'八万零四百五十四' num2chn(80454)
Notes
- Support up to 16-digit number.
- Decimals only supported in the
currency
form, in other forms, the decimal part will be ignored. - Do not support negative numbers. the negative sign
(-)
will be ignored.