MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / GetCharacterRef

Method GetCharacterRef

sourcecommon/tinyxml2.cpp:318–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316
317
318const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
319{
320 // Presume an entity, and pull it out.
321 *length = 0;
322
323 if ( *(p+1) == '#' && *(p+2) ) {
324 unsigned long ucs = 0;
325 ptrdiff_t delta = 0;
326 unsigned mult = 1;
327
328 if ( *(p+2) == 'x' ) {
329 // Hexadecimal.
330 if ( !*(p+3) ) {
331 return 0;
332 }
333
334 const char* q = p+3;
335 q = strchr( q, ';' );
336
337 if ( !q || !*q ) {
338 return 0;
339 }
340
341 delta = q-p;
342 --q;
343
344 while ( *q != 'x' ) {
345 if ( *q >= '0' && *q <= '9' ) {
346 ucs += mult * (*q - '0');
347 }
348 else if ( *q >= 'a' && *q <= 'f' ) {
349 ucs += mult * (*q - 'a' + 10);
350 }
351 else if ( *q >= 'A' && *q <= 'F' ) {
352 ucs += mult * (*q - 'A' + 10 );
353 }
354 else {
355 return 0;
356 }
357 mult *= 16;
358 --q;
359 }
360 }
361 else {
362 // Decimal.
363 if ( !*(p+2) ) {
364 return 0;
365 }
366
367 const char* q = p+2;
368 q = strchr( q, ';' );
369
370 if ( !q || !*q ) {
371 return 0;
372 }
373
374 delta = q-p;
375 --q;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected