| 226 | } |
| 227 | |
| 228 | const char* AnnotationResTable::format_numberic(const char *hex_str, int fmt) |
| 229 | { |
| 230 | assert(hex_str); |
| 231 | |
| 232 | if (hex_str[0] == 0 || fmt == DecoderDataFormat::hex){ |
| 233 | return hex_str; |
| 234 | } |
| 235 | |
| 236 | //check if have split letter |
| 237 | const char *rd = hex_str; |
| 238 | bool bMutil = false; |
| 239 | char c = 0; |
| 240 | |
| 241 | while (*rd) |
| 242 | { |
| 243 | c = *rd; |
| 244 | rd++; |
| 245 | |
| 246 | if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) |
| 247 | { |
| 248 | continue; |
| 249 | } |
| 250 | |
| 251 | bMutil = true; |
| 252 | break; |
| 253 | } |
| 254 | |
| 255 | if (!bMutil){ |
| 256 | return format_to_string(hex_str, fmt); |
| 257 | } |
| 258 | |
| 259 | //convert each sub string |
| 260 | char sub_buf[DECODER_MAX_DATA_BLOCK_LEN + 1]; |
| 261 | char *sub_wr = sub_buf; |
| 262 | char *sub_end = sub_wr + DECODER_MAX_DATA_BLOCK_LEN; |
| 263 | char *all_buf = g_all_buf; |
| 264 | char *all_wr = all_buf; |
| 265 | |
| 266 | rd = hex_str; |
| 267 | |
| 268 | while (*rd) |
| 269 | { |
| 270 | c = *rd; |
| 271 | rd++; |
| 272 | |
| 273 | if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')){ |
| 274 | if (sub_wr == sub_end){ |
| 275 | printf("conver error,sub string length is too long!\n"); |
| 276 | return hex_str; |
| 277 | } |
| 278 | |
| 279 | *sub_wr = c; //make sub string |
| 280 | sub_wr++; |
| 281 | continue; |
| 282 | } |
| 283 | |
| 284 | //convert sub string |
| 285 | if (sub_wr != sub_buf){ |