MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / parse_hex4

Function parse_hex4

external/cJSON/cJSON.c:666–699  ·  view source on GitHub ↗

parse 4 digit hexadecimal number */

Source from the content-addressed store, hash-verified

664
665/* parse 4 digit hexadecimal number */
666static unsigned parse_hex4(const unsigned char * const input)
667{
668 unsigned int h = 0;
669 size_t i = 0;
670
671 for (i = 0; i < 4; i++)
672 {
673 /* parse digit */
674 if ((input[i] >= '0') && (input[i] <= '9'))
675 {
676 h += (unsigned int) input[i] - '0';
677 }
678 else if ((input[i] >= 'A') && (input[i] <= 'F'))
679 {
680 h += (unsigned int) 10 + input[i] - 'A';
681 }
682 else if ((input[i] >= 'a') && (input[i] <= 'f'))
683 {
684 h += (unsigned int) 10 + input[i] - 'a';
685 }
686 else /* invalid */
687 {
688 return 0;
689 }
690
691 if (i < 3)
692 {
693 /* shift left to make place for the next nibble */
694 h = h << 4;
695 }
696 }
697
698 return h;
699}
700
701/* converts a UTF-16 literal to UTF-8
702 * A literal can be one or two sequences of the form \uXXXX */

Callers 1

utf16_literal_to_utf8Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected