Function arabia_to_chinese (Num ){
For (I = num. Length-1; I> = 0; I --)
{
Num = num. Replace (",", "") // Replace ","
Num = num. Replace ("", "") // Replace the space in tomoney ()
}
Num = num. Replace ("¥", "") // Replace the possible ¥ characters
If (isnan (Num) {// verify whether the entered character is a number
Alert ("check whether the lower-case amount is correct ");
Return;
}
// --- After the character processing is complete, start to convert. The conversion starts with the first and second parts ---//
Part = string (Num). Split (".");
Newchar = "";
// Convert before decimal point
For (I = part [0]. Length-1; I> = 0; I --){
If (part [0]. length> 10) {alert ("the number of digits is too large to be calculated"); Return ";} // if the number of parts exceeds, a prompt is displayed.
Tmpnewchar = ""
Perchar = part [0]. charat (I );
Switch (perchar ){
Case "0": tmpnewchar = "0" + tmpnewchar; break;
Case "1": tmpnewchar = "" + tmpnewchar; break;
Case "2": tmpnewchar = "" + tmpnewchar; break;
Case "3": tmpnewchar = "" + tmpnewchar; break;
Case "4": tmpnewchar = "Si" + tmpnewchar; break;
Case "5": tmpnewchar = "Wu" + tmpnewchar; break;
Case "6": tmpnewchar = "" + tmpnewchar; break;
Case "7": tmpnewchar = "bytes" + tmpnewchar; break;
Case "8": tmpnewchar = "bytes" + tmpnewchar; break;
Case "9": tmpnewchar = "bytes" + tmpnewchar; break;
}
Switch (part [0]. length-i-1 ){
Case 0: tmpnewchar = tmpnewchar + "Yuan"; break;
Case 1: If (perchar! = 0) tmpnewchar = tmpnewchar + "pick up"; break;
Case 2: If (perchar! = 0) tmpnewchar = tmpnewchar + "bytes"; break;
Case 3: If (perchar! = 0) tmpnewchar = tmpnewchar + "bytes"; break;
Case 4: tmpnewchar = tmpnewchar + "Thousand"; break;
Case 5: If (perchar! = 0) tmpnewchar = tmpnewchar + "pick up"; break;
Case 6: If (perchar! = 0) tmpnewchar = tmpnewchar + "bytes"; break;
Case 7: If (perchar! = 0) tmpnewchar = tmpnewchar + "bytes"; break;
Case 8: tmpnewchar = tmpnewchar + ""; break;
Case 9: tmpnewchar = tmpnewchar + "pick up"; break;
}
Newchar = tmpnewchar + newchar;
}
// Convert the decimal point
If (Num. indexof (".")! =-1 ){
If (part [1]. length> 2 ){
Alert ("Only two digits can be retained after the decimal point, and the system will automatically cut the segment ");
Part [1] = part [1]. substr (0, 2)
}
For (I = 0; I <part [1]. length; I ++ ){
Tmpnewchar = ""
Perchar = part [1]. charat (I)
Switch (perchar ){
Case "0": tmpnewchar = "0" + tmpnewchar; break;
Case "1": tmpnewchar = "" + tmpnewchar; break;
Case "2": tmpnewchar = "" + tmpnewchar; break;
Case "3": tmpnewchar = "" + tmpnewchar; break;
Case "4": tmpnewchar = "Si" + tmpnewchar; break;
Case "5": tmpnewchar = "Wu" + tmpnewchar; break;
Case "6": tmpnewchar = "" + tmpnewchar; break;
Case "7": tmpnewchar = "bytes" + tmpnewchar; break;
Case "8": tmpnewchar = "bytes" + tmpnewchar; break;
Case "9": tmpnewchar = "bytes" + tmpnewchar; break;
}
If (I = 0) tmpnewchar = tmpnewchar + "";
If (I = 1) tmpnewchar = tmpnewchar + "points ";
Newchar = newchar + tmpnewchar;
}
}
// Replace all useless Chinese Characters
While (newchar. Search ("0 ")! =-1)
Newchar = newchar. Replace ("zero", "zero ");
Newchar = newchar. Replace ("0 billion ");
Newchar = newchar. Replace ("hundreds of millions", "hundreds of millions ");
Newchar = newchar. Replace ("0 thousand ");
Newchar = newchar. Replace ("Zero yuan", "Yuan ");
Newchar = newchar. Replace (" ","");
Newchar = newchar. Replace ("0 ","");
If (newchar. charat (newchar. Length-1) = "" | newchar. charat (newchar. Length-1) = "")
Newchar = newchar + "integer"
Return newchar;
}