Convert the amount of lowercase into Chinese characters (JavaScript)

xiaoxiao2021-03-06  94

Function Arabia_to_CHINESE (NUM) {for (i = Num.Length-1; I> = 0; I -) {Num = Num.Replace (",", "") // Replace Tomoney () "," Num = Num.Replace ("," ") // Replace the space in Tomoney ()} Num = Num.Replace (" ¥ "," ") // Replace the possible (ISNAN (NUM) ) {// Verify that the input character is the digital ALERT ("Please check if the lowercase amount is correct"); return;} // --- Character processing, start conversion, conversion adopts the front and rear part of the two partial conversion --- // Part = string (NUM) .split ("."); newchar = ""; // front conversion for conversion for (i = part [0] .length-1; i> = 0; i -) {= Part [0] .length> 10) {Alert ("The number of bits is too large, can't calculate"); return "";} // If the quantity exceeds the pickup unit, TMPNewchar = "" "Perchar = Part [0] .Charat (i); switch (perchar) {copy "0": tmpnewchar = "zero" TmpNewchar; break; case "1": tmpnewchar = "" tmpnewchar; break; casse "2": tmpnewchar = "" TmpNewcha; tmpnewchar = "叁" tmpnewchar; break; case "4": tmpnewchar = "" tmpnewchar; break; case "5": tmpnewchar = "Wu" TmpNewchar; Break; Case "6": tmpnewchar = "Lu" TmpNewcha; Break; Case "7": tmpnewchar = "柒" TmpNewchar; Break; Case "8": tmpnewchar = "捌" tmpnewchar; buk; Case "9": tmpnewchar = "玖" tmpnewchar; break;} switch (part [0] .length-i-1) {case 0: tmpnewchar = tmpnewchar "yuan"; break; casse 1: if (Perchar! = 0) TmpNewchar = TmpNewchar "Pick"; Break; Case 2: IF (Perchar! = 0) TmpNewchar = TmpNewchar ""; Break;

Case 3: IF (percha! = 0) TmpNewchar = TmpNewchar "仟"; Break; Case 4: TmpNewchar = TmpNewcha "10,000"; Break; Case 5: IF (Perchar! = 0) TmpNewchar = TmpNewchar "Pick" Break; Case 6: IF (Perchar! = 0) TMPNewchar = TmpNewcha ""; Break; Case 7: IF (Perchar! = 0) TmpNewchar = TmpNewcha "仟"; Break; Case 8: TmpNewchar = TmpNewchar "Billion"; breaf; casse 9: tmpnewchar = tmpnewchar "Pick"; Break;} Newchar = tmpnewchar newchar;} // Decimal point after transformation IF (Num.indexof (".")! = - 1) {IF (Part [1] .length> 2) {Alert ("Two digits after the decimal point, the system will automatically"); Part [1] = part [1] .substr (0, 2)} for (i = 0; i

Newchar tmpnewchar;}} // Replace all useless Chinese characters while (newchar.search ("zero zero")! = -1) newchar = newchar.replace ("zero zero", "zero"); newchar = newchar.Replace "零", "hundreds"); newchar = newchar.replace ("100 million", "hundreds"); newchar = newchar.replace ("万", "10,000"); newchar = newchar.replace ("zero Yuan, "yuan"); newchar = newchar.replace ("zero", ""); newchar = newchar.replace ("zero", ""); if (newchar.charat (newchar.length-1) == "Yuan" || Newchar.Charat (newchar.length-1) == "angle") newchar = newchar "whole" return newchar;}

转载请注明原文地址:https://www.9cbs.com/read-106741.html

New Post(0)