Skip to content

Escapes control characters with back slashes, such that they are safe to print. Escaped characters are:

codesymboldescription
\0x07\abell
\0x08\bbackspace
\0x09\thorizontal tab
\0x0a\nline feed
\0x0b\vvertical tab
\0x0c\fform feed
\0x0d\rcarriage return
\0x22\"double quote
\0x27\'single quote
\0x5c\\back slash

Usage

escape_cntrl(x, escape_quotes = c("none", "single", "double", "both"))

Arguments

x

A character vector.

escape_quotes

Should quotes be escaped? One of none, single, double, or both.

Value

A character vector with escaped control characters.

Examples

escape_cntrl(c('foo\nbar\t\tbazz', 'foo\abar'))
#> [1] "foo\\nbar\\t\\tbazz" "foo\\abar"