The implementation process of converting amount lowercase to uppercase characters

Source: Internet
Author: User
Tags lowercase modify return
Capital | process | Chinese Character | amount | lowercase

Write yourself a relatively ugly program, but do the report when useful
/********************************************************************
Time: 2003.7.31
Author: Trinidad Pig
Function: Converts currency digits (Arabic numerals) (lowercase) into Chinese (uppercase)

Parameter: num is character type, leaving two digits after the decimal point, for example: Arabia_to_chinese ("1234.06")
Note: 1. At present this conversion only support to pick billion (yuan) bit, the amount of units for the yuan, can not be million, the smallest unit for the minute
2. Negative numbers are not supported
Modify Area

Time:
Modify Person:
Reason:

End of modification area
********************************************************************/
function Arabia_to_chinese (Num) {
for (i=num.length-1;i>=0;i--)
{
Num = Num.replace (",", "")//Replace the "," in Tomoney ()
Num = Num.replace ("", "")//Replace the space in Tomoney ()
}
Num = Num.replace ("¥", "")//replace the possible ¥ characters
if (isNaN (Num)) {//Verify that the character entered is a number
Alert ("Please check the lowercase amount is correct");
Return
}
---character processing finished, start conversion, conversion using the two parts of the conversion---//
Part = String (Num). Split (".");
Newchar = "";
Convert before a decimal point
for (i=part[0].length-1;i>=0;i--) {
if (Part[0].length >) {alert ("too large to compute"); return "";} If the number of more than million units, prompted
Tmpnewchar = ""
Perchar = Part[0].charat (i);
Switch (Perchar) {
Case "0": tmpnewchar= "0" + Tmpnewchar;
Case "1": tmpnewchar= "one" + Tmpnewchar;
Case "2": tmpnewchar= "II" + Tmpnewchar;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.