PostGIS  2.5.0dev-r@@SVN_REVISION@@
uint8_t parse_hex ( char *  str)

Convert a single hex digit into the corresponding char.

Convert a single hex digit into the corresponding char.

No error checking done!

Definition at line 540 of file lwgeom_api.c.

Referenced by rt_raster_from_hexwkb().

541 {
542  /* do this a little brute force to make it faster */
543 
544  uint8_t result_high = 0;
545  uint8_t result_low = 0;
546 
547  switch (str[0])
548  {
549  case '0' :
550  result_high = 0;
551  break;
552  case '1' :
553  result_high = 1;
554  break;
555  case '2' :
556  result_high = 2;
557  break;
558  case '3' :
559  result_high = 3;
560  break;
561  case '4' :
562  result_high = 4;
563  break;
564  case '5' :
565  result_high = 5;
566  break;
567  case '6' :
568  result_high = 6;
569  break;
570  case '7' :
571  result_high = 7;
572  break;
573  case '8' :
574  result_high = 8;
575  break;
576  case '9' :
577  result_high = 9;
578  break;
579  case 'A' :
580  case 'a' :
581  result_high = 10;
582  break;
583  case 'B' :
584  case 'b' :
585  result_high = 11;
586  break;
587  case 'C' :
588  case 'c' :
589  result_high = 12;
590  break;
591  case 'D' :
592  case 'd' :
593  result_high = 13;
594  break;
595  case 'E' :
596  case 'e' :
597  result_high = 14;
598  break;
599  case 'F' :
600  case 'f' :
601  result_high = 15;
602  break;
603  }
604  switch (str[1])
605  {
606  case '0' :
607  result_low = 0;
608  break;
609  case '1' :
610  result_low = 1;
611  break;
612  case '2' :
613  result_low = 2;
614  break;
615  case '3' :
616  result_low = 3;
617  break;
618  case '4' :
619  result_low = 4;
620  break;
621  case '5' :
622  result_low = 5;
623  break;
624  case '6' :
625  result_low = 6;
626  break;
627  case '7' :
628  result_low = 7;
629  break;
630  case '8' :
631  result_low = 8;
632  break;
633  case '9' :
634  result_low = 9;
635  break;
636  case 'A' :
637  case 'a' :
638  result_low = 10;
639  break;
640  case 'B' :
641  case 'b' :
642  result_low = 11;
643  break;
644  case 'C' :
645  case 'c' :
646  result_low = 12;
647  break;
648  case 'D' :
649  case 'd' :
650  result_low = 13;
651  break;
652  case 'E' :
653  case 'e' :
654  result_low = 14;
655  break;
656  case 'F' :
657  case 'f' :
658  result_low = 15;
659  break;
660  }
661  return (uint8_t) ((result_high<<4) + result_low);
662 }
unsigned char uint8_t
Definition: uthash.h:79

Here is the caller graph for this function: