string_escape
Escape text for source-code or markup contexts (JSON, JS, C, shell, HTML, etc.) using the appropriate convention. Supports backslash, entities, unicode, and MIME styles.
Instructions
Escape text for a source-code or markup context (JSON/JS/C/shell/HTML/...).
style picks the convention: json|js|python|c|backslash (backslash escapes),
html|xml (entities), unicode_escape (\uXXXX/\xNN), quoted_printable, or
mime_word (=?UTF-8?B?...?=). shell yields a paste-safe single-quoted token.
For URL %-escaping use encode(scheme='url') instead. An unknown style raises
ValueError. Returns {style, result}. Inverse: string_unescape.
Example: string_escape('a"b', "json") -> result 'a"b'
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to escape. | |
| style | Yes | Escaping convention: json|js|python|c|backslash (backslash escapes), html|xml (entities), unicode_escape, quoted_printable, mime_word (=?UTF-8?B?...?=), or shell (paste-safe single-quoted token). |