Skip to content

@technobuddha > library > Programming > Escaping

Function: unescapeC()

ts
function unescapeC(input: string): string;

Defined in: unescape-c.ts:42

Unescape a string encoded in C style

Escape SequenceHexCharacter
\00x00NUL
\a0x07Bell
\b0x08Backspace
\e0x1bEscape
\f0x0cForm Feed
\n0x0aNew Line
\r0x0dCarriage Return
\t0x09Tab
\v0x0bVertical Tab
\\0x5cBackslash
\'0x27Single Quote
\"0x22Double Quote
\?0x3fQuestion Mark
\nnn[^1]0x0000-0x01ffOctal Escape
\xn…[^2]Hex 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. [^2]: A hex escape sequence must have at least one hex digit following \x, with no upper bound; it continues for as many hex digits as there are.

Parameters

ParameterTypeDescription
inputstringThe string to unescape

Returns

string

the string with escapes resolved

Example

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