Function decimaltochinesecurrency (decimal:string): String; Var
S, t:tstringlist;
I, Ti:integer;
tmps:string;
Isdecimal:integer; Begin Isdecimal: = 0;
TI: = 0;
For I: = 1 to Length (Decimal) do
Begin
If decimal[i] = '. ' Then
Begin INC (Isdecimal);
TI: = i;
End;
If not (decimal[i) in [' 0 ' ... ' 9 ', '. '] Or (Isdecimal > 1) Then
Begin Result: = Decimal;
Exit;
End;
End;
If ti = 0 Then//Decimal position Begin tmps: = decimal + '. ';
TI: = Length (Tmps);
Tmps: = Decimal;
s: = Tstringlist.create;
T: = tstringlist.create;
Try s.delimiter: = ', ';
T.delimiter: = ', ';
S.commatext: = ' 0 = 0, 1 = one, 2 = II, 3 = three, 4 = restaurant, 5 = Wu, 6 = lu, 7 = seven, 8 = BA, 9 = nine;
T.commatext: = ' -1=, 0 = horn, 1 = yuan, 2 = pick, 3 = bai, 4 = thousand, 5= million, 6 = pick, 7 = bai, 8 = thousand, 9= billion, 10 = pick, 11 = bai, 12 = thousand, 13 = trillion, 14 = pick, 15 = bai, 16 = thousand ';
TI: = Length (tmps)-ti;
Tmps: = StringReplace (Tmps, '. ', ', ', [Rfreplaceall]);
For I: = 1 to Length (tmps) do
Begin
If (Tmps[length (tmps)-i + 1] = ' 0 ') and (i Mod 4 = 1) Then
Result: = T.values[inttostr (I-ti)] + result
Else
If (Tmps[length (tmps)-i + 1] = ' 0 ') and (I Mod 4 <> 1) Then
Result: = S.values[tmps[length (tmps)-i + 1]] + result
Else
Result: = S.values[tmps[length (tmps) – i + 1]] + T.VALUES[INTTOSTR (i-ti)] + result;
End;
While Pos (' 00 ", result) > 0 do
Result: = StringReplace (result, ' 00 ', ' 0 ', [Rfreplaceall]);
If Pos (' 0 trillion ', result) > 0 Then Result: = StringReplace (result, ' 0 trillion ', ' trillion ', [rfreplaceall]);
If Pos (' 0 ', result) > 0 Then Result: = StringReplace (result, ' 0 ', ' billion ', [Rfreplaceall]);
If Pos (' 0 ', result) > 0 Then Result: = StringReplace (result, ' 0 ', ' million ', [Rfreplaceall]);
If Pos (' 0 $ ', result) > 0 Then Result: = StringReplace (result, ' 0 ', ' yuan ', [Rfreplaceall]);
If Pos (' Mega billion ', result) > 0 Then Result: = StringReplace (result, ' Mega billion ', ' trillion ', [rfreplaceall]);
If Pos (' billions ', result) > 0 Then Result: = StringReplace (result, ' billions ', ' billion ', [Rfreplaceall]);
If Pos (' Mega million ', result) > 0 Then Result: = StringReplace (result, ' Mega million ', ' trillion ', [rfreplaceall]);
Finally T.free;
S.free;
End;
End;
{=====================================================}
Function Chinesecurrencytodecimal (chinesecurrency:string): String; Var
S:tstringlist;
I, Ti:integer; Begin s: = Tstringlist.create;
Try s.delimiter: = ', ';
S.commatext: = ' Yuan =., 0 = 0, one = 1, ii = 2, three = 3, restaurant = 4, Wu = 5, Lu = 6, Qi = 7, ba = 8, nine = 9 ';
TI: = Length (chinesecurrency) Div 2;
For i: = ti downto 1 do
Result: = S.values[chinesecurrency[i * 2-1] + chinesecurrency[i * 2];
Finally S.free;
End;
End;