王小胖之數字轉大寫

2022-09-15 05:06:11 字數 2643 閱讀 7889

使用場景:一般在書寫正規金額的時候都要求填寫大寫數字。

實現功能:數字轉大寫功能主要實現:輸入小寫阿拉伯數字,轉換成大寫

資料例項:輸入,12345678.90   輸出,人民幣:壹仟貳佰叄拾肆萬伍仟陸佰柒拾捌元玖角

功能實現:

html**

<

div

class

="input-group"

>

<

input

name

="kw"

type

="text"

class

="form-control"

placeholder

="數字"

id="lower"

value

="12345678.90"

>

<

div

class

="input-group-btn"

>

<

button

type

="submit"

class

="btn btn-success"

id="convert"

>轉換

button

>

div>

div>

js**

numberconvert.js

function

convertcurrency(currencydigits)

if (currencydigits.match(/[^,.\d]/) != null

)

if ((currencydigits).match(/^((\d(,\d)*(.((\d,)*\d))?)|(\d+(.\d+)?))$/) == null

)

//normalize the format of input digits:

currencydigits = currencydigits.replace(/,/g, ""); //

remove comma delimiters.

currencydigits = currencydigits.replace(/^0+/, ""); //

trim zeros at the beginning.

//assert the number is not greater than the maximum number.

if (number(currencydigits) >maximum_number)

//process the coversion from currency digits to characters:

//separate integral and decimal parts before processing coversion:

parts = currencydigits.split(".");

if (parts.length > 1)

else

//prepare the characters corresponding to the digits:

digits = new

array(cn_zero, cn_one, cn_two, cn_three, cn_four, cn_five, cn_six, cn_seven, cn_eight, cn_nine);

radices = new array("", cn_ten, cn_hundred, cn_thousand);

bigradices = new array("", cn_ten_thousand, cn_hundred_million);

decimals = new

array(cn_ten_cent, cn_cent);

//start processing:

outputcharacters = "";

//process integral part if it is larger than 0:

if (number(integral) > 0)

else

zerocount = 0;

outputcharacters += digits[number(d)] +radices[modulus];

} if (modulus == 0 && zerocount < 4)

} outputcharacters +=cn_dollar;

} //process decimal part if there is:

if (decimal != "")

} }

//confirm and return the final output string:

if (outputcharacters == "")

if (decimal == "")

outputcharacters = cn_symbol +outputcharacters;

return

outputcharacters;

}

不愛說話,一切以**為主,其他 全靠悟性!

數字轉大寫功能位址:

數字轉大寫

1.js實現方法 static string converttochinese double x return regex.replace d,m 負元空零壹貳叄肆伍陸柒捌玖空空空空空空空分角拾佰仟萬億兆京垓秭穰 m.value 0 tostring 2.c 實現方法 privatestaticst...

王小胖之中文漢字轉拼音

使用場景 看到乙個字不知道讀音,那麼可以複製然後查一下。實現功能 輸入漢字,轉換成帶音標的讀音,重點是能顯示音標,便於學習讀音。資料例項 輸入 王小胖頂呱呱 輸出 w ng xi o p ng d ng gu gu 功能實現 html div class input group input name...

數字小寫轉大寫

加到類的定義部分 private static string cstr privatestatic string wstr 數字必須在12位整數以內的字串 呼叫方式如 label1.text convertint 數字字串 public string convertint string str rs...