- 假如以字符串形式输入,愿意动手的,可以在现在的基础上无限扩展,最好是过亿之后,我建议把字符串拆分成2段,千万亿与千万,除了最终单位亿,其余表达是一样,因为暂时想不到哪里需要用那么大的大写数字,就不写了
- (defun _Cii2BIG(num)
- (cdr (assoc num '((48 . "零")(49 . "一")(50 . "二")(51 . "三")(52 . "四")(53 . "五")(54 . "六")(55 . "七")(56 . "八")(57 . "九"))))
- )
- (defun num2big (num / *error* str lst _biglst _bigunit zuhe chuli1 chuli2)
- (defun *error* (s)
- (vl-bt)
- )
- (if (numberp num)
- (setq str (itoa (fix num)))
- (setq str num)
- )
- (setq lst (vl-string->list str))
- (setq _biglst (mapcar '_Cii2BIG lst))
- (setq _bigunit '("" "十" "百" "千" "万" "十" "百" "千" "亿" "十" "百" "千" "万"))
- ;;;;数字与单位组合
- (setq zuhe (mapcar '(lambda(x y ) (strcat x y)) ( reverse _biglst) _bigunit))
- ;;;;处理与零组合的情况
- (setq chuli1 (mapcar '(lambda(x) (if (wcmatch x "零千,零百,零十") "零"
- (if (wcmatch x "零万,零亿") (vl-string-trim "零" x) x )) ) zuhe))
- ;;;;处理从个位开始是0的
- (while (and (> (length chuli1) 1)(wcmatch (car chuli1) "零*"))
- (setq chuli1 (cdr chuli1))
- )
- ;;;;连接处理过后的组合
- (setq chuli2 (apply 'strcat (reverse chuli1)))
- (cond
- ((wcmatch chuli2 "*零零零零亿*")(setq chuli2(vl-string-subst "" "零零零零亿" chuli2)))
- ((wcmatch chuli2 "*零零零亿*")(setq chuli2(vl-string-subst "亿" "零零零亿" chuli2)))
- ((wcmatch chuli2 "*零零亿*")(setq chuli2(vl-string-subst "亿" "零零亿" chuli2)))
- ((wcmatch chuli2 "*零亿*")(setq chuli2(vl-string-subst "亿" "零亿" chuli2)))
- )
- (cond
- ((wcmatch chuli2 "*零零零万*")(setq chuli2(vl-string-subst "" "零零零万" chuli2)))
- ((wcmatch chuli2 "*零零万*")(setq chuli2(vl-string-subst "万" "零零万" chuli2)))
- ((wcmatch chuli2 "*零万*")(setq chuli2(vl-string-subst "万" "零万" chuli2)))
- )
- (while (wcmatch chuli2 "*零零*")
- (setq chuli2 (vl-string-subst "零" "零零" chuli2))
- )
- (if (wcmatch chuli2 "一十*")
- (setq chuli2 (vl-string-subst "十" "一十" chuli2))
- )
- chuli2
- )
|