在IVR或语音提示中会用到很多播报数值或金额的片段,现提供源代码以供参考,如下:
TransNum.h 文件
#ifndef _TransNum_H_
#define _TransNum_H_
#include "KYLib.h"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 常量定义 */
// 转换元素项(translate element item)
#define TEI_0 0 // 0
#define TEI_1 1 // 1
#define TEI_2 2 // 2
#define TEI_3 3 // 3
#define TEI_4 4 // 4
#define TEI_5 5 // 5
#define TEI_6 6 // 6
#define TEI_7 7 // 7
#define TEI_8 8 // 8
#define TEI_9 9 // 9
#define TEI_10 10 // 10
#define TEI_20 11 // 20
#define TEI_30 12 // 30
#define TEI_40 13 // 40
#define TEI_50 14 // 50
#define TEI_60 15 // 60
#define TEI_70 16 // 70
#define TEI_80 17 // 80
#define TEI_90 18 // 90
#define TEI_10_2 19 // 百
#define TEI_10_3 20 // 千
#define TEI_10_4 21 // 万
#define TEI_10_8 22 // 亿
#define TEI_Dot 23 // 点
#define TEI_Minus 24 // 负
#define TEI_Count 25 // 元素项个数
// 扩充转换元素项(translate element item)
#define TEI_Yuan TEI_Count // 元
#define TEI_Jiao TEI_Count+1 // 角
#define TEI_Fen TEI_Count+2 // 分
#define TEI_End TEI_Count+3 // 整
#define TEI_Count1 TEI_End+1 // 扩充后元素项个数
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 公用函数 */
// 转换数字串为元素项列表
// 参数:
// APos 数字串的开始位置, 并返回结尾或非数字串
// AEnd 数字串的结尾, 若为 NULL 则判断'\0'结尾符号
// AElements 存放返回元素项列表, 不允许为 NULL
// AMaxSize AElements 列表的最大尺寸
// 返回值:
// > 0 返回元素项个数
// 0 调用失败, APos不是['0'..'9', '.', '-']开头
// -1 调用失败, 参数不合法
// -2 调用失败, 元素列表的尺寸不足
long NumToElements(char* &APos, const char* AEnd, char* AElements, long AMaxSize);
// 扩充为金额的元角分元素(注: AElements 的 MaxSize >= ACount + 2)
long ExtractYJFElements(char* AElements, long ACount);
// 元素列表转换成自定义字符串(ATEList 项数至少为 TEI_Count)
KYString ElementsToCustom(const KYString* ATEList, const char* AElements, long ACount);
// 元素列表转换成数量读法字符串
KYString ElementsToQuantity(const char* AElements, long ACount);
// 元素列表转换成大写金额字符串
KYString ElementsToMoney(const char* AElements, long ACount);
#endif
#ifndef _TransNum_H_
#define _TransNum_H_
#include "KYLib.h"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 常量定义 */
// 转换元素项(translate element item)
#define TEI_0 0 // 0
#define TEI_1 1 // 1
#define TEI_2 2 // 2
#define TEI_3 3 // 3
#define TEI_4 4 // 4
#define TEI_5 5 // 5
#define TEI_6 6 // 6
#define TEI_7 7 // 7
#define TEI_8 8 // 8
#define TEI_9 9 // 9
#define TEI_10 10 // 10
#define TEI_20 11 // 20
#define TEI_30 12 // 30
#define TEI_40 13 // 40
#define TEI_50 14 // 50
#define TEI_60 15 // 60
#define TEI_70 16 // 70
#define TEI_80 17 // 80
#define TEI_90 18 // 90
#define TEI_10_2 19 // 百
#define TEI_10_3 20 // 千
#define TEI_10_4 21 // 万
#define TEI_10_8 22 // 亿
#define TEI_Dot 23 // 点
#define TEI_Minus 24 // 负
#define TEI_Count 25 // 元素项个数
// 扩充转换元素项(translate element item)
#define TEI_Yuan TEI_Count // 元
#define TEI_Jiao TEI_Count+1 // 角
#define TEI_Fen TEI_Count+2 // 分
#define TEI_End TEI_Count+3 // 整
#define TEI_Count1 TEI_End+1 // 扩充后元素项个数
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 公用函数 */
// 转换数字串为元素项列表
// 参数:
// APos 数字串的开始位置, 并返回结尾或非数字串
// AEnd 数字串的结尾, 若为 NULL 则判断'\0'结尾符号
// AElements 存放返回元素项列表, 不允许为 NULL
// AMaxSize AElements 列表的最大尺寸
// 返回值:
// > 0 返回元素项个数
// 0 调用失败, APos不是['0'..'9', '.', '-']开头
// -1 调用失败, 参数不合法
// -2 调用失败, 元素列表的尺寸不足
long NumToElements(char* &APos, const char* AEnd, char* AElements, long AMaxSize);
// 扩充为金额的元角分元素(注: AElements 的 MaxSize >= ACount + 2)
long ExtractYJFElements(char* AElements, long ACount);
// 元素列表转换成自定义字符串(ATEList 项数至少为 TEI_Count)
KYString ElementsToCustom(const KYString* ATEList, const char* AElements, long ACount);
// 元素列表转换成数量读法字符串
KYString ElementsToQuantity(const char* AElements, long ACount);
// 元素列表转换成大写金额字符串
KYString ElementsToMoney(const char* AElements, long ACount);
#endif
TransNum.cpp 文件
#include "TransNum.h"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 常量定义 */
// 数量元素列表
static const KYString _TE_Quanitys[TEI_Count]
= {"零", // 0
"一", // 1
"二", // 2
"三", // 3
"四", // 4
"五", // 5
"六", // 6
"七", // 7
"八", // 8
"九", // 9
"十", // 10
"二十", // 20
"三十", // 30
"四十", // 40
"五十", // 50
"六十", // 60
"七十", // 70
"八十", // 80
"九十", // 90
"百", // 百
"千", // 千
"万", // 万
"亿", // 亿
"点", // 点
"负"}; // 负
// 金额元素列表
static const KYString _TE_Moneys[TEI_Count1]
= {"零", // 0
"壹", // 1
"贰", // 2
"叁", // 3
"肆", // 4
"伍", // 5
"陆", // 6
"柒", // 7
"捌", // 8
"玖", // 9
"壹拾", // 10
"贰拾", // 20
"叁拾", // 30
"肆拾", // 40
"伍拾", // 50
"陆拾", // 60
"柒拾", // 70
"捌拾", // 80
"玖拾", // 90
"佰", // 百
"仟", // 千
"万", // 万
"亿", // 亿
"点", // 点
"负", // 负
"元", // 元
"角", // 角
"分", // 分
"整"}; // 整
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 内部函数 */
// 扫描数字串并清除左边的'0'字符
static long ScanDigitAndTrimLeft(char* &APos)
{
// 过滤 '0' 字符
char* pBegin = APos;
while (*APos == '0')
APos++;
// 判断前缀是否为 '0'
bool boolPrefix = (pBegin != APos);
// 继续扫描
pBegin = APos;
while ((*APos >= '0') && (*APos <= '9'))
APos++;
// 计算长度
long result = APos - pBegin;
if (result == 0)
result = boolPrefix;
// 返回结果
return result;
}
// 扫描数字串并清除左边的'0'字符
static long ScanDigitAndTrimLeft(char* &APos, const char* AEnd)
{
// 过滤 '0' 字符
char* pBegin = APos;
while ((APos < AEnd) && (*APos == '0'))
APos++;
// 判断前缀是否为 '0'
bool boolPrefix = (pBegin != APos);
// 继续扫描
pBegin = APos;
while ((APos < AEnd) && (*APos >= '0') && (*APos <= '9'))
APos++;
// 计算长度
long result = APos - pBegin;
if (result == 0)
result = boolPrefix;
// 返回结果
return result;
}
// 扫描数字串并清除右边的'0'字符
static long ScanDigitAndTrimRight(char* &APos)
{
// 初始化
char* pBegin = APos;
char* pLast = APos;
// 循环扫描
while ((*APos >= '0') && (*APos <= '9'))
{
if (*APos != '0')
pLast = APos + 1;
APos++;
}
// 返回结果
return (pLast - pBegin);
}
// 扫描数字串并清除右边的'0'字符
static long ScanDigitAndTrimRight(char* &APos, const char* AEnd)
{
// 初始化
char* pBegin = APos;
char* pLast = APos;
// 循环扫描
while ((APos < AEnd) && (*APos >= '0') && (*APos <= '9'))
{
if (*APos != '0')
pLast = APos + 1;
APos++;
}
// 返回结果
return (pLast - pBegin);
}
// 4位数转换并返回元素项个数
static long Digit4ToElements(char* &ADigit, char ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
// 静态常量
static const char Digit_Unit[4] = {TEI_0, TEI_10, TEI_10_2, TEI_10_3};
static const char Digit_Ten[10] = {TEI_0, TEI_10, TEI_20, TEI_30, TEI_40,
TEI_50, TEI_60, TEI_70, TEI_80, TEI_90};
// 初始化
char charItem;
bool boolZero = false;
char* pBegin = AElement;
// 循环计算
while (ANum > 0)
{
// 得到元素项
charItem = *ADigit - '0';
ADigit++;
ANum--;
// 判断是否为 0
if (charItem == 0)
boolZero = true;
else
{
// 添加连接 0
if (boolZero)
{
boolZero = false;
*AElement++ = TEI_0;
}
// 检查是否溢出
if (AElement >= AEnd)
{
AIsOverflow = true;
break;
}
else if (ANum == 1)
*AElement++ = Digit_Ten[charItem];
else
{
// 保存元素项
*AElement++ = charItem;
if (ANum == 0)
;
else if (AElement < AEnd)
*AElement++ = Digit_Unit[ANum];
else
{
AIsOverflow = true;
break;
}
}
}
}
// 返回结果
return (AElement - pBegin);
}
// 8位数转换并返回元素项个数
static long Digit8ToElements(char* &ADigit, char ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
if (ANum <= 4)
return Digit4ToElements(ADigit, ANum, AElement, AEnd, AIsOverflow);
else
{
long result = Digit4ToElements(ADigit, ANum - 4, AElement, AEnd, AIsOverflow);
if (!AIsOverflow)
{
// 添加单位(万)
if (result == 0)
;
else if (AElement < AEnd)
{
*AElement++ = TEI_10_4;
result++;
}
else
AIsOverflow = true;
// 判断是否溢出
if (!AIsOverflow)
result += Digit4ToElements(ADigit, 4, AElement, AEnd, AIsOverflow);
}
return result;
}
}
// 多位数转换并返回元素项个数
static long DigitsToElements(char* &ADigit, long ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
if (ANum <= 8)
return Digit8ToElements(ADigit, (char)ANum, AElement, AEnd, AIsOverflow);
else
{
// 初始化
char charHead = ANum & 0x07;
long intCycle = ANum >> 3;
// 判断是否 8 位对齐
if (charHead == 0)
{
charHead = 8;
intCycle--;
}
// 最高几位
long intNo;
long intSub = Digit8ToElements(ADigit, charHead, AElement, AEnd, AIsOverflow);
long result = intSub;
// 循环处理
while (!AIsOverflow && (intCycle > 0))
{
// 添加单位(亿)
if (intSub == 0)
;
else if (AElement <= AEnd - intCycle)
for (intNo = 0; intNo < intCycle; intNo++)
{
*AElement++ = TEI_10_8;
result++;
}
else
AIsOverflow = true;
// 判断是否溢出
if (!AIsOverflow)
{
intSub = Digit8ToElements(ADigit, 8, AElement, AEnd, AIsOverflow);
result += intSub;
intCycle--;
}
}
// 返回结果
return result;
}
}
// 小数点之后的数字转换并返回元素项个数
static long DecimalToElements(char* ADecimal, long ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
if (AElement <= AEnd - ANum)
{
// 循环转换
for (long intNo = 0; intNo < ANum; intNo++, ADecimal++, AElement++)
*AElement = *ADecimal - '0';
// 返回结果
return ANum;
}
else
{
AIsOverflow = true;
return 0;
}
}
// 拷贝字符串
static void CopyString(char* &ADest, const KYString& AStr)
{
long intLen = AStr.Length();
if (intLen > 0)
{
memcpy(ADest, (char*)AStr, intLen);
ADest += intLen;
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 公用函数 */
// 转换数字串为元素项列表
// 参数:
// APos 数字串的开始位置, 并返回结尾或非数字串
// AEnd 数字串的结尾, 若为 NULL 则判断'\0'结尾符号
// AElements 存放返回元素项列表, 不允许为 NULL
// AMaxSize AElements 列表的最大尺寸
// 返回值:
// > 0 返回元素项个数
// 0 调用失败, APos不是['0'..'9', '.', '-']开头
// -1 调用失败, 参数不合法
// -2 调用失败, 元素列表的尺寸不足
long NumToElements(char* &APos, const char* AEnd, char* AElements, long AMaxSize)
{
// 检查参数是否非法
if ((APos == NULL) || (AElements == NULL) || (AMaxSize <= 0))
return -1;
else if (((*APos < '0') || (*APos > '9')) && (*APos != '.') && (*APos != '-'))
return 0;
// 初始化
long result = 0;
bool boolOverflow = false;
char* pElementEnd = AElements + AMaxSize;
long intLeft = 0;
long intRight = 0;
char* pLeft = NULL;
char* pRight = NULL;
// 负号
if (*APos == '-')
{
*AElements++ = TEI_Minus;
result++;
APos++;
}
// 判断是否以'\0'字符结尾
if (AEnd == NULL)
{
// 扫描左边数字串
intLeft = ScanDigitAndTrimLeft(APos);
if (intLeft > 0)
{
pLeft = APos - intLeft;
intLeft = DigitsToElements(pLeft, intLeft, AElements,
pElementEnd, boolOverflow);
result += intLeft;
}
// 检查是否溢出, 并判断是否存在小数点
if (boolOverflow)
result = -2;
else if (*APos == '.')
{
APos++;
pRight = APos;
intRight = ScanDigitAndTrimRight(APos);
if (intRight > 0)
{
// 判断是否需要添加 0
if (intLeft == 0)
{
*AElements++ = TEI_0;
result++;
}
// 检查元素列表容量
if (AElements < pElementEnd + intRight)
{
*AElements++ = TEI_Dot;
result++;
result += DecimalToElements(pRight, intRight, AElements,
pElementEnd, boolOverflow);
}
else
result = -2;
}
else if (intLeft == 0)
result = 0;
}
else if (intLeft == 0)
result = 0;
}
else
{
// 扫描左边数字串
intLeft = ScanDigitAndTrimLeft(APos, AEnd);
if (intLeft > 0)
{
pLeft = APos - intLeft;
intLeft = DigitsToElements(pLeft, intLeft, AElements,
pElementEnd, boolOverflow);
result += intLeft;
}
// 检查是否溢出, 并判断是否存在小数点
if (boolOverflow)
result = -2;
else if ((APos < AEnd) && (*APos == '.'))
{
APos++;
pRight = APos;
intRight = ScanDigitAndTrimRight(APos, AEnd);
if (intRight > 0)
{
// 判断是否需要添加 0
if (intLeft == 0)
{
*AElements++ = TEI_0;
result++;
}
// 检查元素列表容量
if (AElements < pElementEnd + intRight)
{
*AElements++ = TEI_Dot;
result++;
result += DecimalToElements(pRight, intRight, AElements,
pElementEnd, boolOverflow);
}
else
result = -2;
}
else if (intLeft == 0)
result = 0;
}
else if (intLeft == 0)
result = 0;
}
// 返回结果
return result;
}
// 扩充为金额的元角分元素(注: AElements 的 MaxSize >= ACount + 2)
long ExtractYJFElements(char* AElements, long ACount)
{
// 查找小数点
long intDot = -1;
for (long intNo = 0; intNo < ACount; intNo++, AElements++)
if (*AElements == TEI_Dot)
{
intDot = intNo;
break;
}
// 初始化
long result = (intDot >= 0) ? intDot : ACount;
bool boolEnd = true;
// 添加元
*AElements++ = TEI_Yuan;
result++;
// 判断是否存在小数点
if ((intDot >= 0) && (intDot < ACount - 1))
{
// 取分值
char charFen = (intDot < ACount - 2) ? AElements[1] : 0;
// 检查角是否非 0
if (*AElements != 0)
{
*AElements++;
*AElements++ = TEI_Jiao;
boolEnd = false;
result += 2;
}
// 检查分是否非 0
if (charFen != 0)
{
*AElements++ = charFen;
*AElements = TEI_Fen;
boolEnd = false;
result += 2;
}
}
// 判断是否需要添加
if (boolEnd)
{
*AElements = TEI_End;
result++;
}
// 返回结果
return result;
}
// 元素列表转换成自定义字符串(ATEList 项数至少为 TEI_Count)
KYString ElementsToCustom(const KYString* ATEList, const char* AElements, long ACount)
{
// 初始化
KYString result;
// 检查参数
if ((ATEList != NULL) && (AElements != NULL) && (ACount > 0))
{
// 初始化
long intNo;
long intSize = 0;
char* pElement = (char*)AElements;
char* pPos;
// 计算尺寸
for (intNo = 0; intNo < ACount; intNo++, pElement++)
intSize += ATEList[*pElement].Length();
// 分配内存并拷贝数据
result.SetLength(intSize);
pPos = (char*)result;
pElement = (char*)AElements;
for (intNo = 0; intNo < ACount; intNo++, pElement++)
CopyString(pPos, ATEList[*pElement]);
}
// 返回结果
return result;
}
// 元素列表转换成数量读法字符串
KYString ElementsToQuantity(const char* AElements, long ACount)
{
return ElementsToCustom(_TE_Quanitys, AElements, ACount);
}
// 元素列表转换成大写金额字符串
KYString ElementsToMoney(const char* AElements, long ACount)
{
return ElementsToCustom(_TE_Moneys, AElements, ACount);
}
#include "TransNum.h"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 常量定义 */
// 数量元素列表
static const KYString _TE_Quanitys[TEI_Count]
= {"零", // 0
"一", // 1
"二", // 2
"三", // 3
"四", // 4
"五", // 5
"六", // 6
"七", // 7
"八", // 8
"九", // 9
"十", // 10
"二十", // 20
"三十", // 30
"四十", // 40
"五十", // 50
"六十", // 60
"七十", // 70
"八十", // 80
"九十", // 90
"百", // 百
"千", // 千
"万", // 万
"亿", // 亿
"点", // 点
"负"}; // 负
// 金额元素列表
static const KYString _TE_Moneys[TEI_Count1]
= {"零", // 0
"壹", // 1
"贰", // 2
"叁", // 3
"肆", // 4
"伍", // 5
"陆", // 6
"柒", // 7
"捌", // 8
"玖", // 9
"壹拾", // 10
"贰拾", // 20
"叁拾", // 30
"肆拾", // 40
"伍拾", // 50
"陆拾", // 60
"柒拾", // 70
"捌拾", // 80
"玖拾", // 90
"佰", // 百
"仟", // 千
"万", // 万
"亿", // 亿
"点", // 点
"负", // 负
"元", // 元
"角", // 角
"分", // 分
"整"}; // 整
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 内部函数 */
// 扫描数字串并清除左边的'0'字符
static long ScanDigitAndTrimLeft(char* &APos)
{
// 过滤 '0' 字符
char* pBegin = APos;
while (*APos == '0')
APos++;
// 判断前缀是否为 '0'
bool boolPrefix = (pBegin != APos);
// 继续扫描
pBegin = APos;
while ((*APos >= '0') && (*APos <= '9'))
APos++;
// 计算长度
long result = APos - pBegin;
if (result == 0)
result = boolPrefix;
// 返回结果
return result;
}
// 扫描数字串并清除左边的'0'字符
static long ScanDigitAndTrimLeft(char* &APos, const char* AEnd)
{
// 过滤 '0' 字符
char* pBegin = APos;
while ((APos < AEnd) && (*APos == '0'))
APos++;
// 判断前缀是否为 '0'
bool boolPrefix = (pBegin != APos);
// 继续扫描
pBegin = APos;
while ((APos < AEnd) && (*APos >= '0') && (*APos <= '9'))
APos++;
// 计算长度
long result = APos - pBegin;
if (result == 0)
result = boolPrefix;
// 返回结果
return result;
}
// 扫描数字串并清除右边的'0'字符
static long ScanDigitAndTrimRight(char* &APos)
{
// 初始化
char* pBegin = APos;
char* pLast = APos;
// 循环扫描
while ((*APos >= '0') && (*APos <= '9'))
{
if (*APos != '0')
pLast = APos + 1;
APos++;
}
// 返回结果
return (pLast - pBegin);
}
// 扫描数字串并清除右边的'0'字符
static long ScanDigitAndTrimRight(char* &APos, const char* AEnd)
{
// 初始化
char* pBegin = APos;
char* pLast = APos;
// 循环扫描
while ((APos < AEnd) && (*APos >= '0') && (*APos <= '9'))
{
if (*APos != '0')
pLast = APos + 1;
APos++;
}
// 返回结果
return (pLast - pBegin);
}
// 4位数转换并返回元素项个数
static long Digit4ToElements(char* &ADigit, char ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
// 静态常量
static const char Digit_Unit[4] = {TEI_0, TEI_10, TEI_10_2, TEI_10_3};
static const char Digit_Ten[10] = {TEI_0, TEI_10, TEI_20, TEI_30, TEI_40,
TEI_50, TEI_60, TEI_70, TEI_80, TEI_90};
// 初始化
char charItem;
bool boolZero = false;
char* pBegin = AElement;
// 循环计算
while (ANum > 0)
{
// 得到元素项
charItem = *ADigit - '0';
ADigit++;
ANum--;
// 判断是否为 0
if (charItem == 0)
boolZero = true;
else
{
// 添加连接 0
if (boolZero)
{
boolZero = false;
*AElement++ = TEI_0;
}
// 检查是否溢出
if (AElement >= AEnd)
{
AIsOverflow = true;
break;
}
else if (ANum == 1)
*AElement++ = Digit_Ten[charItem];
else
{
// 保存元素项
*AElement++ = charItem;
if (ANum == 0)
;
else if (AElement < AEnd)
*AElement++ = Digit_Unit[ANum];
else
{
AIsOverflow = true;
break;
}
}
}
}
// 返回结果
return (AElement - pBegin);
}
// 8位数转换并返回元素项个数
static long Digit8ToElements(char* &ADigit, char ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
if (ANum <= 4)
return Digit4ToElements(ADigit, ANum, AElement, AEnd, AIsOverflow);
else
{
long result = Digit4ToElements(ADigit, ANum - 4, AElement, AEnd, AIsOverflow);
if (!AIsOverflow)
{
// 添加单位(万)
if (result == 0)
;
else if (AElement < AEnd)
{
*AElement++ = TEI_10_4;
result++;
}
else
AIsOverflow = true;
// 判断是否溢出
if (!AIsOverflow)
result += Digit4ToElements(ADigit, 4, AElement, AEnd, AIsOverflow);
}
return result;
}
}
// 多位数转换并返回元素项个数
static long DigitsToElements(char* &ADigit, long ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
if (ANum <= 8)
return Digit8ToElements(ADigit, (char)ANum, AElement, AEnd, AIsOverflow);
else
{
// 初始化
char charHead = ANum & 0x07;
long intCycle = ANum >> 3;
// 判断是否 8 位对齐
if (charHead == 0)
{
charHead = 8;
intCycle--;
}
// 最高几位
long intNo;
long intSub = Digit8ToElements(ADigit, charHead, AElement, AEnd, AIsOverflow);
long result = intSub;
// 循环处理
while (!AIsOverflow && (intCycle > 0))
{
// 添加单位(亿)
if (intSub == 0)
;
else if (AElement <= AEnd - intCycle)
for (intNo = 0; intNo < intCycle; intNo++)
{
*AElement++ = TEI_10_8;
result++;
}
else
AIsOverflow = true;
// 判断是否溢出
if (!AIsOverflow)
{
intSub = Digit8ToElements(ADigit, 8, AElement, AEnd, AIsOverflow);
result += intSub;
intCycle--;
}
}
// 返回结果
return result;
}
}
// 小数点之后的数字转换并返回元素项个数
static long DecimalToElements(char* ADecimal, long ANum, char* &AElement,
const char* AEnd, bool& AIsOverflow)
{
if (AElement <= AEnd - ANum)
{
// 循环转换
for (long intNo = 0; intNo < ANum; intNo++, ADecimal++, AElement++)
*AElement = *ADecimal - '0';
// 返回结果
return ANum;
}
else
{
AIsOverflow = true;
return 0;
}
}
// 拷贝字符串
static void CopyString(char* &ADest, const KYString& AStr)
{
long intLen = AStr.Length();
if (intLen > 0)
{
memcpy(ADest, (char*)AStr, intLen);
ADest += intLen;
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 公用函数 */
// 转换数字串为元素项列表
// 参数:
// APos 数字串的开始位置, 并返回结尾或非数字串
// AEnd 数字串的结尾, 若为 NULL 则判断'\0'结尾符号
// AElements 存放返回元素项列表, 不允许为 NULL
// AMaxSize AElements 列表的最大尺寸
// 返回值:
// > 0 返回元素项个数
// 0 调用失败, APos不是['0'..'9', '.', '-']开头
// -1 调用失败, 参数不合法
// -2 调用失败, 元素列表的尺寸不足
long NumToElements(char* &APos, const char* AEnd, char* AElements, long AMaxSize)
{
// 检查参数是否非法
if ((APos == NULL) || (AElements == NULL) || (AMaxSize <= 0))
return -1;
else if (((*APos < '0') || (*APos > '9')) && (*APos != '.') && (*APos != '-'))
return 0;
// 初始化
long result = 0;
bool boolOverflow = false;
char* pElementEnd = AElements + AMaxSize;
long intLeft = 0;
long intRight = 0;
char* pLeft = NULL;
char* pRight = NULL;
// 负号
if (*APos == '-')
{
*AElements++ = TEI_Minus;
result++;
APos++;
}
// 判断是否以'\0'字符结尾
if (AEnd == NULL)
{
// 扫描左边数字串
intLeft = ScanDigitAndTrimLeft(APos);
if (intLeft > 0)
{
pLeft = APos - intLeft;
intLeft = DigitsToElements(pLeft, intLeft, AElements,
pElementEnd, boolOverflow);
result += intLeft;
}
// 检查是否溢出, 并判断是否存在小数点
if (boolOverflow)
result = -2;
else if (*APos == '.')
{
APos++;
pRight = APos;
intRight = ScanDigitAndTrimRight(APos);
if (intRight > 0)
{
// 判断是否需要添加 0
if (intLeft == 0)
{
*AElements++ = TEI_0;
result++;
}
// 检查元素列表容量
if (AElements < pElementEnd + intRight)
{
*AElements++ = TEI_Dot;
result++;
result += DecimalToElements(pRight, intRight, AElements,
pElementEnd, boolOverflow);
}
else
result = -2;
}
else if (intLeft == 0)
result = 0;
}
else if (intLeft == 0)
result = 0;
}
else
{
// 扫描左边数字串
intLeft = ScanDigitAndTrimLeft(APos, AEnd);
if (intLeft > 0)
{
pLeft = APos - intLeft;
intLeft = DigitsToElements(pLeft, intLeft, AElements,
pElementEnd, boolOverflow);
result += intLeft;
}
// 检查是否溢出, 并判断是否存在小数点
if (boolOverflow)
result = -2;
else if ((APos < AEnd) && (*APos == '.'))
{
APos++;
pRight = APos;
intRight = ScanDigitAndTrimRight(APos, AEnd);
if (intRight > 0)
{
// 判断是否需要添加 0
if (intLeft == 0)
{
*AElements++ = TEI_0;
result++;
}
// 检查元素列表容量
if (AElements < pElementEnd + intRight)
{
*AElements++ = TEI_Dot;
result++;
result += DecimalToElements(pRight, intRight, AElements,
pElementEnd, boolOverflow);
}
else
result = -2;
}
else if (intLeft == 0)
result = 0;
}
else if (intLeft == 0)
result = 0;
}
// 返回结果
return result;
}
// 扩充为金额的元角分元素(注: AElements 的 MaxSize >= ACount + 2)
long ExtractYJFElements(char* AElements, long ACount)
{
// 查找小数点
long intDot = -1;
for (long intNo = 0; intNo < ACount; intNo++, AElements++)
if (*AElements == TEI_Dot)
{
intDot = intNo;
break;
}
// 初始化
long result = (intDot >= 0) ? intDot : ACount;
bool boolEnd = true;
// 添加元
*AElements++ = TEI_Yuan;
result++;
// 判断是否存在小数点
if ((intDot >= 0) && (intDot < ACount - 1))
{
// 取分值
char charFen = (intDot < ACount - 2) ? AElements[1] : 0;
// 检查角是否非 0
if (*AElements != 0)
{
*AElements++;
*AElements++ = TEI_Jiao;
boolEnd = false;
result += 2;
}
// 检查分是否非 0
if (charFen != 0)
{
*AElements++ = charFen;
*AElements = TEI_Fen;
boolEnd = false;
result += 2;
}
}
// 判断是否需要添加
if (boolEnd)
{
*AElements = TEI_End;
result++;
}
// 返回结果
return result;
}
// 元素列表转换成自定义字符串(ATEList 项数至少为 TEI_Count)
KYString ElementsToCustom(const KYString* ATEList, const char* AElements, long ACount)
{
// 初始化
KYString result;
// 检查参数
if ((ATEList != NULL) && (AElements != NULL) && (ACount > 0))
{
// 初始化
long intNo;
long intSize = 0;
char* pElement = (char*)AElements;
char* pPos;
// 计算尺寸
for (intNo = 0; intNo < ACount; intNo++, pElement++)
intSize += ATEList[*pElement].Length();
// 分配内存并拷贝数据
result.SetLength(intSize);
pPos = (char*)result;
pElement = (char*)AElements;
for (intNo = 0; intNo < ACount; intNo++, pElement++)
CopyString(pPos, ATEList[*pElement]);
}
// 返回结果
return result;
}
// 元素列表转换成数量读法字符串
KYString ElementsToQuantity(const char* AElements, long ACount)
{
return ElementsToCustom(_TE_Quanitys, AElements, ACount);
}
// 元素列表转换成大写金额字符串
KYString ElementsToMoney(const char* AElements, long ACount)
{
return ElementsToCustom(_TE_Moneys, AElements, ACount);
}
测试代码:
#include <stdio.h>
#include "TransNum.h"
// 语音文件元素列表
static const KYString _TE_Voices[TEI_Count1]
= {"s_0.wav,", // 0
"s_1.wav,", // 1
"s_2.wav,", // 2
"s_3.wav,", // 3
"s_4.wav,", // 4
"s_5.wav,", // 5
"s_6.wav,", // 6
"s_7.wav,", // 7
"s_8.wav,", // 8
"s_9.wav,", // 9
"s_10.wav,", // 10
"s_20.wav,", // 20
"s_30.wav,", // 30
"s_40.wav,", // 40
"s_50.wav,", // 50
"s_60.wav,", // 60
"s_70.wav,", // 70
"s_80.wav,", // 80
"s_90.wav,", // 90
"s_10_2.wav,", // 百
"s_10_3.wav,", // 千
"s_10_4.wav,", // 万
"s_10_8.wav,", // 亿
"s_dot.wav,", // 点
"s_minu.wav,", // 负
"s_yuan.wav,", // 元
"s_jiao.wav,", // 角
"s_fen.wav,", // 分
"s_end.wav,"}; // 整
// 输出转换结果
static void OutputTransResult(TKYDebugFile& AFile, const KYString& AValue)
{
// 静态常量
static const KYString Log_Line = "----------------------------------------"
"----------------------------------------";
static const KYString Fmt_Log1 = "translate {length: %d, value: %s}";
static const KYString Fmt_Log2 = "elements {return: %d, pos: %d, max: %d}";
static const KYString Fmt_Log3 = "extractYJF{return: %d}";
static const KYString Fmt_Log4 = "quantity {%s}";
static const KYString Fmt_Log5 = "money {%s}";
static const KYString Fmt_Log6 = "voices {%s}";
// 初始化
KYString strElements;
long intCount, intLen;
char* pElements;
char* pBegin = (char*)AValue;
char* pPos = pBegin;
// 分配元素列表缓冲区
intLen = AValue.Length();
strElements.SetLength(intLen + intLen);
pElements = (char*)strElements;
// 转换数字串为元素项列表
AFile.WriteFmt(Time(), Fmt_Log1, intLen, pBegin);
intCount = NumToElements(pPos, pBegin + intLen, pElements, strElements.Length());
AFile.WriteFmt(Time(), Fmt_Log2, intCount, pPos - pBegin + 1, strElements.Length());
// 若转换元素表成功则输出
if (intCount > 0)
{
// 初始化
KYString strResult;
strResult = ElementsToQuantity(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log4, (char*)strResult);
strResult = ElementsToMoney(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log5, (char*)strResult);
strResult = ElementsToCustom(_TE_Voices, pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log6, (char*)strResult);
intCount = ExtractYJFElements(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log3, intCount);
strResult = ElementsToMoney(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log5, (char*)strResult);
strResult = ElementsToCustom(_TE_Voices, pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log6, (char*)strResult);
}
// 结束
AFile.Write(Log_Line);
}
// 主函数
int main(int argc, char* argv[])
{
// 静态常量
static const KYString File_Config = "Translate.ini";
static const KYString File_Output = "Translate.txt";
static const KYString Name_Sect = "config";
static const KYString Key_Count = "count";
static const KYString Fmt_Item = "value_%d";
// 初始化
TKYDebugFile objFile;
// 打开输出文件
if (objFile.Open(CurrAppFilePath + File_Output, false))
{
// 初始化
long intNo, intCount;
KYString strValue;
TIniFile iniConfig(CurrAppFilePath + File_Config);
// 循环输出
intCount = iniConfig.ReadInteger(Name_Sect, Key_Count, 0);
for (intNo = 0; intNo < intCount; intNo++)
{
strValue = iniConfig.ReadString(Name_Sect, Format(Fmt_Item, intNo), "");
if (strValue.Length() != 0)
OutputTransResult(objFile, strValue);
}
}
else
printf("output file <%s> opens failure!\n", (char*)File_Output);
// 返回
return 0;
}
#include <stdio.h>
#include "TransNum.h"
// 语音文件元素列表
static const KYString _TE_Voices[TEI_Count1]
= {"s_0.wav,", // 0
"s_1.wav,", // 1
"s_2.wav,", // 2
"s_3.wav,", // 3
"s_4.wav,", // 4
"s_5.wav,", // 5
"s_6.wav,", // 6
"s_7.wav,", // 7
"s_8.wav,", // 8
"s_9.wav,", // 9
"s_10.wav,", // 10
"s_20.wav,", // 20
"s_30.wav,", // 30
"s_40.wav,", // 40
"s_50.wav,", // 50
"s_60.wav,", // 60
"s_70.wav,", // 70
"s_80.wav,", // 80
"s_90.wav,", // 90
"s_10_2.wav,", // 百
"s_10_3.wav,", // 千
"s_10_4.wav,", // 万
"s_10_8.wav,", // 亿
"s_dot.wav,", // 点
"s_minu.wav,", // 负
"s_yuan.wav,", // 元
"s_jiao.wav,", // 角
"s_fen.wav,", // 分
"s_end.wav,"}; // 整
// 输出转换结果
static void OutputTransResult(TKYDebugFile& AFile, const KYString& AValue)
{
// 静态常量
static const KYString Log_Line = "----------------------------------------"
"----------------------------------------";
static const KYString Fmt_Log1 = "translate {length: %d, value: %s}";
static const KYString Fmt_Log2 = "elements {return: %d, pos: %d, max: %d}";
static const KYString Fmt_Log3 = "extractYJF{return: %d}";
static const KYString Fmt_Log4 = "quantity {%s}";
static const KYString Fmt_Log5 = "money {%s}";
static const KYString Fmt_Log6 = "voices {%s}";
// 初始化
KYString strElements;
long intCount, intLen;
char* pElements;
char* pBegin = (char*)AValue;
char* pPos = pBegin;
// 分配元素列表缓冲区
intLen = AValue.Length();
strElements.SetLength(intLen + intLen);
pElements = (char*)strElements;
// 转换数字串为元素项列表
AFile.WriteFmt(Time(), Fmt_Log1, intLen, pBegin);
intCount = NumToElements(pPos, pBegin + intLen, pElements, strElements.Length());
AFile.WriteFmt(Time(), Fmt_Log2, intCount, pPos - pBegin + 1, strElements.Length());
// 若转换元素表成功则输出
if (intCount > 0)
{
// 初始化
KYString strResult;
strResult = ElementsToQuantity(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log4, (char*)strResult);
strResult = ElementsToMoney(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log5, (char*)strResult);
strResult = ElementsToCustom(_TE_Voices, pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log6, (char*)strResult);
intCount = ExtractYJFElements(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log3, intCount);
strResult = ElementsToMoney(pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log5, (char*)strResult);
strResult = ElementsToCustom(_TE_Voices, pElements, intCount);
AFile.WriteFmt(Time(), Fmt_Log6, (char*)strResult);
}
// 结束
AFile.Write(Log_Line);
}
// 主函数
int main(int argc, char* argv[])
{
// 静态常量
static const KYString File_Config = "Translate.ini";
static const KYString File_Output = "Translate.txt";
static const KYString Name_Sect = "config";
static const KYString Key_Count = "count";
static const KYString Fmt_Item = "value_%d";
// 初始化
TKYDebugFile objFile;
// 打开输出文件
if (objFile.Open(CurrAppFilePath + File_Output, false))
{
// 初始化
long intNo, intCount;
KYString strValue;
TIniFile iniConfig(CurrAppFilePath + File_Config);
// 循环输出
intCount = iniConfig.ReadInteger(Name_Sect, Key_Count, 0);
for (intNo = 0; intNo < intCount; intNo++)
{
strValue = iniConfig.ReadString(Name_Sect, Format(Fmt_Item, intNo), "");
if (strValue.Length() != 0)
OutputTransResult(objFile, strValue);
}
}
else
printf("output file <%s> opens failure!\n", (char*)File_Output);
// 返回
return 0;
}
测试例子结果:
view plaincopy to clipboardprint?
11:42:14.828 -> translate {length: 5, value: -asdf}
11:42:14.828 -> elements {return: 0, pos: 2, max: 10}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 11, value: -0000000100}
11:42:14.828 -> elements {return: 3, pos: 12, max: 22}
11:42:14.828 -> quantity {负一百}
11:42:14.828 -> money {负壹佰}
11:42:14.828 -> voices {s_minu.wav,s_1.wav,s_10_2.wav,}
11:42:14.828 -> extractYJF{return: 5}
11:42:14.828 -> money {负壹佰元整}
11:42:14.828 -> voices {s_minu.wav,s_1.wav,s_10_2.wav,s_yuan.wav,s_end.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 28, value: -0000000000100.1000000000000}
11:42:14.828 -> elements {return: 5, pos: 29, max: 56}
11:42:14.828 -> quantity {负一百点一}
11:42:14.828 -> money {负壹佰点壹}
11:42:14.828 -> voices {s_minu.wav,s_1.wav,s_10_2.wav,s_dot.wav,s_1.wav,}
11:42:14.828 -> extractYJF{return: 6}
11:42:14.828 -> money {负壹佰元壹角}
11:42:14.828 -> voices {s_minu.wav,s_1.wav,s_10_2.wav,s_yuan.wav,s_1.wav,s_jiao.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 41, value: 001000000002333330000333333000.0000040000}
11:42:14.828 -> elements {return: 37, pos: 42, max: 82}
11:42:14.828 -> quantity {一千亿亿亿零二百三十三亿亿三千三百三十万零三亿三千三百三十三万三千点零零零零零四}
11:42:14.828 -> money {壹仟亿亿亿零贰佰叁拾叁亿亿叁仟叁佰叁拾万零叁亿叁仟叁佰叁拾叁万叁仟点零零零零零肆}
11:42:14.828 -> voices {s_1.wav,s_10_3.wav,s_10_8.wav,s_10_8.wav,s_10_8.wav,s_0.wav,s_2.wav,s_10_2.wav,s_30.wav,s_3.wav,s_10_8.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_30.wav,s_10_4.wav,s_0.wav,s_3.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_30.wav,s_3.wav,s_10_4.wav,s_3.wav,s_10_3.wav,s_dot.wav,s_0.wav,s_0.wav,s_0.wav,s_0.wav,s_0.wav,s_4.wav,}
11:42:14.828 -> extractYJF{return: 32}
11:42:14.828 -> money {壹仟亿亿亿零贰佰叁拾叁亿亿叁仟叁佰叁拾万零叁亿叁仟叁佰叁拾叁万叁仟元整}
11:42:14.828 -> voices {s_1.wav,s_10_3.wav,s_10_8.wav,s_10_8.wav,s_10_8.wav,s_0.wav,s_2.wav,s_10_2.wav,s_30.wav,s_3.wav,s_10_8.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_30.wav,s_10_4.wav,s_0.wav,s_3.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_30.wav,s_3.wav,s_10_4.wav,s_3.wav,s_10_3.wav,s_yuan.wav,s_end.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 42, value: 000000000000002489034000234899345.20920000}
11:42:14.828 -> elements {return: 33, pos: 43, max: 84}
11:42:14.828 -> quantity {二百四十八亿亿九千零三十四万零二亿三千四百八十九万九千三百四十五点二零九二}
11:42:14.828 -> money {贰佰肆拾捌亿亿玖仟零叁拾肆万零贰亿叁仟肆佰捌拾玖万玖仟叁佰肆拾伍点贰零玖贰}
11:42:14.828 -> voices {s_2.wav,s_10_2.wav,s_40.wav,s_8.wav,s_10_8.wav,s_10_8.wav,s_9.wav,s_10_3.wav,s_0.wav,s_30.wav,s_4.wav,s_10_4.wav,s_0.wav,s_2.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_4.wav,s_10_2.wav,s_80.wav,s_9.wav,s_10_4.wav,s_9.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_40.wav,s_5.wav,s_dot.wav,s_2.wav,s_0.wav,s_9.wav,s_2.wav,}
11:42:14.828 -> extractYJF{return: 31}
11:42:14.828 -> money {贰佰肆拾捌亿亿玖仟零叁拾肆万零贰亿叁仟肆佰捌拾玖万玖仟叁佰肆拾伍元贰角}
11:42:14.828 -> voices {s_2.wav,s_10_2.wav,s_40.wav,s_8.wav,s_10_8.wav,s_10_8.wav,s_9.wav,s_10_3.wav,s_0.wav,s_30.wav,s_4.wav,s_10_4.wav,s_0.wav,s_2.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_4.wav,s_10_2.wav,s_80.wav,s_9.wav,s_10_4.wav,s_9.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_40.wav,s_5.wav,s_yuan.wav,s_2.wav,s_jiao.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 10, value: 1991.23993}
11:42:14.828 -> elements {return: 12, pos: 11, max: 20}
11:42:14.828 -> quantity {一千九百九十一点二三九九三}
11:42:14.828 -> money {壹仟玖佰玖拾壹点贰叁玖玖叁}
11:42:14.828 -> voices {s_1.wav,s_10_3.wav,s_9.wav,s_10_2.wav,s_90.wav,s_1.wav,s_dot.wav,s_2.wav,s_3.wav,s_9.wav,s_9.wav,s_3.wav,}
11:42:14.828 -> extractYJF{return: 11}
11:42:14.828 -> money {壹仟玖佰玖拾壹元贰角叁分}
11:42:14.828 -> voices {s_1.wav,s_10_3.wav,s_9.wav,s_10_2.wav,s_90.wav,s_1.wav,s_yuan.wav,s_2.wav,s_jiao.wav,s_3.wav,s_fen.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 20, value: 90899900002399.01023}
11:42:14.828 -> elements {return: 21, pos: 21, max: 40}
11:42:14.828 -> quantity {九十万八千九百九十九亿二千三百九十九点零一零二三}
11:42:14.828 -> money {玖拾万捌仟玖佰玖拾玖亿贰仟叁佰玖拾玖点零壹零贰叁}
11:42:14.828 -> voices {s_90.wav,s_10_4.wav,s_8.wav,s_10_3.wav,s_9.wav,s_10_2.wav,s_90.wav,s_9.wav,s_10_8.wav,s_2.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_90.wav,s_9.wav,s_dot.wav,s_0.wav,s_1.wav,s_0.wav,s_2.wav,s_3.wav,}
11:42:14.828 -> extractYJF{return: 18}
11:42:14.828 -> money {玖拾万捌仟玖佰玖拾玖亿贰仟叁佰玖拾玖元壹分}
11:42:14.828 -> voices {s_90.wav,s_10_4.wav,s_8.wav,s_10_3.wav,s_9.wav,s_10_2.wav,s_90.wav,s_9.wav,s_10_8.wav,s_2.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_90.wav,s_9.wav,s_yuan.wav,s_1.wav,s_fen.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 11, value: 98832212000}
11:42:14.828 -> elements {return: 14, pos: 12, max: 22}
11:42:14.828 -> quantity {九百八十八亿三千二百二十一万二千}
11:42:14.828 -> money {玖佰捌拾捌亿叁仟贰佰贰拾壹万贰仟}
11:42:14.828 -> voices {s_9.wav,s_10_2.wav,s_80.wav,s_8.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_2.wav,s_10_2.wav,s_20.wav,s_1.wav,s_10_4.wav,s_2.wav,s_10_3.wav,}
11:42:14.828 -> extractYJF{return: 16}
11:42:14.828 -> money {玖佰捌拾捌亿叁仟贰佰贰拾壹万贰仟元整}
11:42:14.828 -> voices {s_9.wav,s_10_2.wav,s_80.wav,s_8.wav,s_10_8.wav,s_3.wav,s_10_3.wav,s_2.wav,s_10_2.wav,s_20.wav,s_1.wav,s_10_4.wav,s_2.wav,s_10_3.wav,s_yuan.wav,s_end.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 6, value: 100200}
11:42:14.828 -> elements {return: 5, pos: 7, max: 12}
11:42:14.828 -> quantity {十万零二百}
11:42:14.828 -> money {壹拾万零贰佰}
11:42:14.828 -> voices {s_10.wav,s_10_4.wav,s_0.wav,s_2.wav,s_10_2.wav,}
11:42:14.828 -> extractYJF{return: 7}
11:42:14.828 -> money {壹拾万零贰佰元整}
11:42:14.828 -> voices {s_10.wav,s_10_4.wav,s_0.wav,s_2.wav,s_10_2.wav,s_yuan.wav,s_end.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 8, value: 23000000}
11:42:14.828 -> elements {return: 5, pos: 9, max: 16}
11:42:14.828 -> quantity {二千三百万}
11:42:14.828 -> money {贰仟叁佰万}
11:42:14.828 -> voices {s_2.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_10_4.wav,}
11:42:14.828 -> extractYJF{return: 7}
11:42:14.828 -> money {贰仟叁佰万元整}
11:42:14.828 -> voices {s_2.wav,s_10_3.wav,s_3.wav,s_10_2.wav,s_10_4.wav,s_yuan.wav,s_end.wav,}
--------------------------------------------------------------------------------
11:42:14.828 -> translate {length: 15, value: 293000000000000}
11:42:14.828 -> elements {return: 6, pos: 16, max: 30}
11:42:14.828 -> quantity {二百九十三万亿}
11:42:14.828 -> money {贰佰玖拾叁万亿}
11:42:14.828 -> voices {s_2.wav,s_10_2.wav,s_90.wav,s_3.wav,s_10_4.wav,s_10_8.wav,}
11:42:14.828 -> extractYJF{return: 8}
11:42:14.828 -> money {贰佰玖拾叁万亿元整}
11:42:14.828 -> voices {s_2.wav,s_10_2.wav,s_90.wav,s_3.wav,s_10_4.wav,s_10_8.wav,s_yuan.wav,s_end.wav,}
--------------------------------------------------------------------------------
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/kyee/archive/2009/11/07/4783425.aspx
posted on 2011-05-22 12:51
Kyee Ye 阅读(245)
评论(0) 编辑 收藏 引用 所属分类:
源码