Learn R Programming

ctypesio (version 0.1.2)

read_str: Read a character string from a connection

Description

Read character string from a connection.

Usage

read_str(con)

read_str_raw(con, n)

read_utf8(con)

read_utf8_raw(con, n)

Value

single character string

Arguments

con

Connection object or raw vector. Connection objects can be created with file(), url(), rawConnection() or any of the other many connection creation functions.

n

number of characters to read.

Details

Functions which have a suffix of _raw are for handling character strings without a nul-terminator.

See Also

Other data input functions: read_f64(), read_hex(), read_raw(), read_uint8(), scan_dbl()

Examples

Run this code
con <- rawConnection(c(charToRaw("hello12.3"), as.raw(0)))
read_str(con)
close(con)

con <- rawConnection(charToRaw("hello12.3"))
read_str_raw(con, 5)
close(con)

con <- rawConnection(c(charToRaw("hello12.3"), as.raw(0)))
read_utf8(con)
close(con)

con <- rawConnection(charToRaw("hello12.3"))
read_utf8_raw(con, 3)
close(con)

Run the code above in your browser using DataLab