Make R use C notation when escaping terminals

Viewed 274

Not sure I am using the right terminology here, but I need the print or deparse methods use C notation (e.g. "\x05" instead of "\005" ) when escaping bytes out of the regular character set.

x <- "This is a \x05 symbol"
print(x)
[1] "This is a \005 symbol"

Is there a native way to accomplish this?

I need this for generating BSON: http://bsonspec.org/#/specification. All of the examples explicitly use \x05 notation.

2 Answers
Related