There are many ways to convert Arabic numerals into Chinese uppercase. This article will introduce how to implement Arabic numerals in Javascript. For more information, see
The Code is as follows:
Function NoToChinese (num ){
If (! /^ \ D * (\. \ d *)? $/. Test (num) {alert ("Number is wrong! "); Return" Number is wrong! ";}
Var AA = new Array ("zero", "one", "two", "three", "Si", "Wu", "Lu", "Lu ", "success", "fail ");
Var BB = new Array ("", "Pick", "success", "point ","");
Var a = ("" + num ). replace (/(^ 0 *)/g ,""). split (". "), k = 0, re = "";
For (var I = a [0]. length-1; I> = 0; I --){
Switch (k ){
Case 0: re = BB [7] + re; break;
Case 4: if (! New RegExp ("0 {4} \ d {" + (a [0]. length-I-1) + "} $ "). test (a [0])
Re = BB [4] + re; break;
Case 8: re = BB [5] + re; BB [7] = BB [5]; k = 0; break;
}
If (k % 4 = 2 & a [0]. charAt (I + 2 )! = 0 & a [0]. charAt (I + 1) = 0) re = AA [0] + re;
If (a [0]. charAt (I )! = 0) re = AA [a [0]. charAt (I)] + BB [k % 4] + re; k ++;
}
If (a. length> 1) // Add the fractional part (if any)
{
Re + = BB [6];
For (var I = 0; I <a [1]. length; I ++) re + = AA [a [1]. charAt (I)];
}
Return re;
}