MCPcopy Index your code
hub / github.com/callstack/agent-device / decodeNumericXmlEntity

Function decodeNumericXmlEntity

src/utils/xml.ts:346–358  ·  view source on GitHub ↗
(entity: string, body: string)

Source from the content-addressed store, hash-verified

344}
345
346function decodeNumericXmlEntity(entity: string, body: string): string {
347 const codePoint = body.startsWith('#x')
348 ? Number.parseInt(body.slice(2), 16)
349 : Number(body.slice(1));
350 if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 0x10ffff) {
351 return entity;
352 }
353 try {
354 return String.fromCodePoint(codePoint);
355 } catch {
356 return entity;
357 }
358}

Callers 1

decodeXmlEntitiesFunction · 0.70

Calls 1

startsWithMethod · 0.80

Tested by

no test coverage detected