getConsoleEncoding
String Encodings for Input/Output to the Console

Description

Read or set the string encoding used to convert strings typed into or printed to the console.

Usage

getConsoleEncoding()
setConsoleEncoding(encoding)
getConsoleCodePage()

Arguments

encoding a character string specifying a character encoding.

Details

When running TIBCO Enterprise Runtime for R within a console window, characters can be read and printed incorrectly if the console window expects a different string encoding for input/output characters. For example, a basic console window in US Windows uses the CP437 character encoding, which represents some accented characters with different byte values than encodings such as latin1 or UTF-8. To address this problem, TIBCO Enterprise Runtime for R automatically converts between internal string encodings and the "console encoding" when inputting or printing characters.
Specifically, the TIBCO Enterprise Runtime for R engine automatically converts any characters printed to the standard output stream (stdout) or standard error stream (stderr) to the "console encoding", and converts any characters read from the standard input stream (stdin) from this console encoding into an internal string encoding.
The current console encoding can be retrieved with getConsoleEncoding, and set with setConsoleEncoding.
The initial value for the console encoding can be set using the --console-encoding option when starting the console application. If this is not set, it normally defaults to the "native encoding" for the engine (see getNativeEncoding).
On Windows, a console process has a current "code page", an integer that specifies the character set supported by the console. The TIBCO Enterprise Runtime for R console application attempts to set the default native encoding and console encoding from this value. For example, if the code page is 437, it attempts to use the encoding CP437 if it is a supported encoding. The process console code page can be retrieved with getConsoleCodePage.
Value
getConsoleEncoding returns a character string giving the current console string encoding.
getConsoleCodePage returns an integer specifying the Windows code page for this process's console. It returns -1 if this is not running on Windows.
See Also
Encoding, stdout, stderr, stdin, getNativeEncoding.
Examples
## Not run: 
# set the console encoding to any supported encoding
setConsoleEncoding('CP437')

## End(Not run)

# get the current console encoding getConsoleEncoding()

# get the current console code page getConsoleCodePage()

Package terrUtils version 6.0.0-69
Package Index