Digital amount converts Chinese characters

zhaozj2021-02-16  63

// Digital amount converts Chinese characters

Function Atoc (NumberValue) {

VAR NumberValue = new string (Math.Round (NumberValue * 100)); // Digital amount

Var chinesevalue = ""; // Translated Chinese characters

Var string1 = "Zero Zibo"; // Chinese characters

Var string2 = "Wan Yiyi picks up hundreds of millions of 佰 佰 万 佰 佰"; // correspondence unit

VAR LEN = NumberValue.Length; // NumberValue string length

VAR ch1; // digital Chinese reading

VAR CH2; // Digital bits of Chinese character reading

VAR NZERO = 0; // Used to calculate the number of continuous zero values

Var string3; // Specify the value of the location

IF (len> 15) {

Alert ("Beyond Calculation Scope");

""; "

}

IF (NumberValue == 0) {

ChineseValue = "Zero Yuan";

Return ChineseValue;

}

String2 = string2.substr (String2.Length-Len, LEN); // Remove the value of string2 of the corresponding number

For (var i = 0; i

String3 = PARSEINT (NumberValue.substr (i, 1), 10); // Remove the value of a bit you need to convert

// alert (string3);

IF (I! = (LEN - 3) && I! = (LEN - 7) && I! = (LEN - 11) && I! = (LEN - 15)) {

IF (String3 == 0) {

CH1 = "";

CH2 = "";

NZERO = NZERO 1;

} else if (string3! = 0 && nzero! = 0) {

CH1 = "zero" string1.substr (String3, 1);

CH2 = String2.substr (i, 1);

NZERO = 0;

} else {

CH1 = String1.substr (string3, 1);

CH2 = String2.substr (i, 1);

NZERO = 0;

}

} else {// This bit is a key to trillion, billion, million, and yuan.

IF (String3! = 0 && Nzero! = 0) {

CH1 = "zero" string1.substr (String3, 1);

CH2 = String2.substr (i, 1);

NZERO = 0;

} else if (string3! = 0 && nzero == 0) {

CH1 = String1.substr (string3, 1);

CH2 = String2.substr (i, 1);

NZERO = 0;

} else if (string3 == 0 && nzero> = 3) {CH1 = ""

CH2 = "";

NZERO = NZERO 1;

} else {

CH1 = "";

CH2 = String2.substr (i, 1);

NZERO = NZERO 1;

}

IF (i == (LEN - 11) || i == (LEN - 3)) {// If this bit is a billion or a ballad, you must write

CH2 = String2.substr (i, 1);

}

}

ChineseValue = ChineseValue CH1 CH2;

}

IF (string3 == 0) {// The last one (minute) is 0, plus "whole"

ChineseValue = ChineseValue "whole";

}

Return ChineseValue;

}

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

New Post(0)