its implemented through pillar_shaft.character method
function (x, ..., min_width = NULL)
{
x <- utf8::utf8_encode(x)
out <- x
needs_quotes <- which(is_ambiguous_string(x))
if (has_length(needs_quotes)) {
out[needs_quotes] <- gsub("\"", "\\\"", x[needs_quotes],
fixed = TRUE)
out[!is.na(x)] <- paste0(style_subtle("\""), out[!is.na(x)],
style_subtle("\""))
na_indent <- 1
}
etc...
I suppose you may be enquiring mostly about pillar:::is_ambiguous_string
function (x)
{
!is.na(x) & grepl("^$|^ | $|\\\\|\"", x)
}