MCPcopy Create free account
hub / github.com/glideapps/quicktype / escapeNonPrintableMapper

Function escapeNonPrintableMapper

src/Strings.ts:149–171  ·  view source on GitHub ↗
(
    printablePredicate: (codePoint: number) => boolean,
    escaper: (codePoint: number) => string
)

Source from the content-addressed store, hash-verified

147}
148
149export function escapeNonPrintableMapper(
150 printablePredicate: (codePoint: number) => boolean,
151 escaper: (codePoint: number) => string
152): (u: number) => string {
153 function mapper(u: number): string {
154 switch (u) {
155 case 0x5c:
156 return "\\\\";
157 case 0x22:
158 return '\\"';
159 case 0x0a:
160 return "\\n";
161 case 0x09:
162 return "\\t";
163 default:
164 if (printablePredicate(u)) {
165 return String.fromCharCode(u);
166 }
167 return escaper(u);
168 }
169 }
170 return mapper;
171}
172
173export const utf16StringEscape = utf16ConcatMap(escapeNonPrintableMapper(isPrintable, standardUnicodeHexEscape));
174export const stringEscape = utf32ConcatMap(escapeNonPrintableMapper(isPrintable, standardUnicodeHexEscape));

Callers 3

Java.tsFile · 0.90
Swift.tsFile · 0.90
Strings.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…