encodeString
Encode Character Vector for Printing

Description

Encodes the special characters contained in a character string to prepare the characters for printing.

Usage

encodeString(x, width = 0, quote = "", na.encode = TRUE,
    justify = c("left", "right", "centre", "none"))

Arguments

x a character vector.
width an integer that specifies the minimum width of the encoded strings. It can be NULL or NA, which means width should use the maximum length of elements in x as its value.
quote The characters to use to enclose the character string that you specify in x. If you specify an empty string, the character string x is not enclosed. Typical characters are either a set of double quotation marks ("") or a set of single quotation marks (' '). The default is a set of double quotation marks ("").
na.encode a logical value. If TRUE, the missing value characters NA are encoded as the character string "NA". If FALSE, the representation of missing values, NA, is retained. The default is TRUE.
justify a character string that specifies the justification of character strings relative to each other. You can specify one of "none", "left", "right", and "centre". When you specify a value for this argument, you need to provide only the first letter of a value.

Details

This function automatically escapes each occurence of any special character in the set (\n, \t, \b, \r, \a, \f, \v) and also the quote character (if specified).
If the character string is composed of unicode characters, the function returns the unicode character code for those characters.
Value
returns a character vector with all special characters encoded.
See Also
format, print.
Examples
encodeString(c('5"2\'', NA, 'new\nline'), quote='"')
encodeString(c('5"2\'', NA, 'new\nline'), na.encode=FALSE)

Package base version 6.1.4-13
Package Index