Skip to content

@technobuddha > library > Programming > Escaping

Function: unescapePython() ​

ts
function unescapePython(input: string): string;

Defined in: unescape-python.ts:38

Unescape a string encoded in Python style

Escape SequenceHexCharacter
\a0x07Bell
\b0x08Backspace
\e0x1bEscape
\f0x0cForm Feed
\n0x0aNew Line
\r0x0dCarriage Return
\t0x09Tab
\v0x0bVertical Tab
\\0x5cBackslash
\'0x27Single Quote
\"0x22Double Quote
\n…n[^1]0x0000-0x01ffOctal Escape
\xnnHex Escape
\unnnn0x0000-0xFFFFUnicode Escape
\Unnnnnnnn0x0000-0x10FFFFUnicode Escape

[^1]: An octal escape sequence consists of a backslash followed by one to three octal digits. The octal escape sequence ends when it either contains three octal digits, or the next character is not an octal digit.

Parameters ​

ParameterTypeDescription
inputstringThe string to unescape

Returns ​

string

the string with escapes resolved

Example ​

typescript
unescapePython('Hello\\nWorld'); // "Hello\nWorld"
unescapePython('\\u20ac'); // "€"
unescapePython('\\x48\\x65\\x6c\\x6c\\x6f'); // "Hello"
unescapePython('\\U0001f600'); // "😀"