atoi_hex
2011-08-18 22:15
99 查看
_LIT(KText, "F12A01");
TInt num_hex = atoi_hex(KText);
TInt num_hex = atoi_hex(KText);
#define is_hex_num0(a) ((a) >= '0' && (a) <= '9') #define is_hex_numa(a) ((a) >= 'a' && (a) <= 'f') #define is_hex_numA(a) ((a) >= 'A' && (a) <= 'F') #define unichar_to_int(ch, num) do {\ if (is_hex_num0(ch)) {\ num = (num * 0x10) + (ch - '0');\ }\ else if (is_hex_numa(ch)) {\ num = (num * 0x10) + (ch - 'a') + 0xa;\ }\ else if (is_hex_numA(ch)) {\ num = (num * 0x10) + (ch - 'A') + 0xA;\ }\ else\ num = KErrGeneral;\ } while(0) TInt atoi_hex(const TDesC& buf)//like this: _LIT(KText, "F12A01"); { TInt i = 0; TInt num = 0; TInt len = buf.Length(); while(i < len) { TInt8 ch = buf[i++]; unichar_to_int(ch, num); if (num == KErrGeneral) return KErrGeneral; } return num; }
相关文章推荐
- atoi实现
- atoi()函数的实现
- C实现atoi()函数和itoa()函数
- 使用FlyMcu将hex文件下载到智芯一号步骤
- LeetCode--String to Integer (atoi)字符串转数字
- C/C++ atoi、atof与itoa函数的实现
- LeetCode 08:string to int(atoi)(C++实现)
- 【Leetcode】String to Integer (atoi)
- leetcode 8. String to Integer (atoi)
- [LeetCode] String to Integer (atoi)
- LeetCode String to Integer (atoi)
- atoi() 函数与 itoa() 函数:字符串与数值之间的转换
- C语言itoa()函数和atoi()函数详解(整数转字符C实现)
- LeetCode--string-to-integer-atoi(atoi库函数的实现)
- [LeetCode] 8. String to Integer (atoi)
- leetcode---string-to-integer-atoi---字符串
- 实现atoi这个函数,将一个字符串转换为整数。如果没有合法的整数,返回0。如果整数超出了32位整数的范围,返回INT_MAX(2147483647)如果是正整数
- C语言atoi()函数:将字符串转换成int(整数)
- python函数回顾:hex()
- VBS教程:函数-Hex 函数