MCPcopy Create free account
hub / github.com/cloudflare/agents / escapeControlChar

Function escapeControlChar

packages/codemode/src/utils.ts:107–113  ·  view source on GitHub ↗

* Escape a character as a unicode escape sequence if it is a control character.

(ch: string)

Source from the content-addressed store, hash-verified

105 * Escape a character as a unicode escape sequence if it is a control character.
106 */
107function escapeControlChar(ch: string): string {
108 const code = ch.charCodeAt(0);
109 if (code <= 0x1f || code === 0x7f) {
110 return "\\u" + code.toString(16).padStart(4, "0");
111 }
112 return ch;
113}
114
115/**
116 * Quote a property name if needed.

Callers 2

quotePropFunction · 0.85
escapeStringLiteralFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected