MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / GetCharacterRef

Method GetCharacterRef

3rdparty/tinyxml2/tinyxml2.cpp:470–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468
469
470const char* XMLUtil::GetCharacterRef(const char* p, char* value, int* length)
471{
472 // Assume an entity, and pull it out.
473 *length = 0;
474
475 static const uint32_t MAX_CODE_POINT = 0x10FFFF;
476
477 if (*(p + 1) == '#' && *(p + 2)) {
478 uint32_t ucs = 0;
479 ptrdiff_t delta = 0;
480 uint32_t mult = 1;
481 static const char SEMICOLON = ';';
482
483 bool hex = false;
484 uint32_t radix = 10;
485 const char* q = 0;
486 char terminator = '#';
487
488 if (*(p + 2) == 'x') {
489 // Hexadecimal.
490 hex = true;
491 radix = 16;
492 terminator = 'x';
493
494 q = p + 3;
495 }
496 else {
497 // Decimal.
498 q = p + 2;
499 }
500 if (!(*q)) {
501 return 0;
502 }
503
504 q = strchr(q, SEMICOLON);
505 if (!q) {
506 return 0;
507 }
508 TIXMLASSERT(*q == SEMICOLON);
509
510 delta = q - p;
511 --q;
512
513 while (*q != terminator) {
514 uint32_t digit = 0;
515
516 if (*q >= '0' && *q <= '9') {
517 digit = *q - '0';
518 }
519 else if (hex && (*q >= 'a' && *q <= 'f')) {
520 digit = *q - 'a' + 10;
521 }
522 else if (hex && (*q >= 'A' && *q <= 'F')) {
523 digit = *q - 'A' + 10;
524 }
525 else {
526 return 0;
527 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected