MCPcopy Create free account
hub / github.com/WheretIB/nullc / strconv_escape

Function strconv_escape

external/pugixml/pugixml.cpp:1449–1580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1447 };
1448
1449 char_t* strconv_escape(char_t* s, gap& g)
1450 {
1451 char_t* stre = s + 1;
1452
1453 switch (*stre)
1454 {
1455 case '#': // &#...
1456 {
1457 unsigned int ucsc = 0;
1458
1459 if (stre[1] == 'x') // &#x... (hex code)
1460 {
1461 stre += 2;
1462
1463 char_t ch = *stre;
1464
1465 if (ch == ';') return stre;
1466
1467 for (;;)
1468 {
1469 if (static_cast<unsigned int>(ch - '0') <= 9)
1470 ucsc = 16 * ucsc + (ch - '0');
1471 else if (static_cast<unsigned int>((ch | ' ') - 'a') <= 5)
1472 ucsc = 16 * ucsc + ((ch | ' ') - 'a' + 10);
1473 else if (ch == ';')
1474 break;
1475 else // cancel
1476 return stre;
1477
1478 ch = *++stre;
1479 }
1480
1481 ++stre;
1482 }
1483 else // &#... (dec code)
1484 {
1485 char_t ch = *++stre;
1486
1487 if (ch == ';') return stre;
1488
1489 for (;;)
1490 {
1491 if (static_cast<unsigned int>(ch - '0') <= 9)
1492 ucsc = 10 * ucsc + (ch - '0');
1493 else if (ch == ';')
1494 break;
1495 else // cancel
1496 return stre;
1497
1498 ch = *++stre;
1499 }
1500
1501 ++stre;
1502 }
1503
1504 #ifdef PUGIXML_WCHAR_MODE
1505 s = reinterpret_cast<char_t*>(wchar_writer::any(reinterpret_cast<wchar_writer::value_type>(s), ucsc));
1506 #else

Callers 5

parseMethod · 0.85
parse_wnormMethod · 0.85
parse_wconvMethod · 0.85
parse_eolMethod · 0.85
parse_simpleMethod · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected