MCPcopy Create free account
hub / github.com/denoland/std / serializeDisplayString

Function serializeDisplayString

http/unstable_structured_fields.ts:1377–1399  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

1375}
1376
1377function serializeDisplayString(value: string): string {
1378 const bytes = UTF8_ENCODER.encode(value);
1379
1380 let result = '%"';
1381 for (const byte of bytes) {
1382 if (byte === 0x25) {
1383 // % -> %25
1384 result += "%25";
1385 } else if (byte === 0x22) {
1386 // " -> %22
1387 result += "%22";
1388 } else if (byte >= 0x20 && byte <= 0x7e) {
1389 // Printable ASCII
1390 result += String.fromCharCode(byte);
1391 } else {
1392 // Percent-encode non-ASCII
1393 result += "%" + byte.toString(16).padStart(2, "0");
1394 }
1395 }
1396 result += '"';
1397
1398 return result;
1399}
1400
1401function serializeParameters(parameters: Parameters): string {
1402 let result = "";

Callers 1

serializeBareItemFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected