strip_ctl(sprintf("%shello %sworld%s", grn.bg, red, end))

strip_ctl(sprintf("%s%shello %sworld%s", grn.bg, inv, red, end))

string[c(2, 4, 6)] <- paste0(red, string[c(2, 4, 6)], end)

[1] "string  1" "string  2" "string  3" "string  4" "string  5" "string  6"
 [7] "string  7" "string  8" "string  9" "string 10"

# Even partially recognized escapes are stripped assuming that they could be
# recognized at all (with the special exception that a single leading ESC will
# be stripped if any control is active).

Argument `x` contains a malformed escape sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

Warning in strip_ctl("hello\033") :
  Argument `x` contains a malformed escape sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

strip_ctl("hello\033", ctl = c("nl", "c0"))

Argument `x` contains a malformed CSI or OSC sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

Warning in strip_ctl("hello\033[") :
  Argument `x` contains a malformed CSI or OSC sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

Warning in strip_ctl("hello\033[42") :
  Argument `x` contains a malformed CSI or OSC sequence at index [1], see `?unhandled_ctl`; you can use `warn=FALSE` to turn off these warnings.

strip_ctl("hello\033[42", ctl = c("all", "csi", "sgr"))

# non-char inputs; really should just coerce to char and move on since we know
# these can't contain the sequences (actually, only true of numerics; other
# objects e.g. Diff can produce chars with sequences)

fansi:::process(" \t\a\r hello", ctl = c("all", "c0"))

# Make sure we are not inadvertently changing SXPs

fansi:::process("hello.\n \t \n \t world")

fansi:::process("hello\033[44m\033[31d world", ctl = c("all", 
    "csi"))

fansi:::process("hello \033[44m\033[31d world", ctl = c("all", 
    "csi"))

fansi:::process("hello \033[44m \033[31d world", ctl = c("all", 
    "csi"))

fansi:::process("hello\033[44m\a world", ctl = c("all"))