read_str: Read a character string from a connection

View source: R/read-utf.R

read_strR Documentation

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)

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.

Value

single character string

See Also

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

Examples

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)

ctypesio documentation built on April 3, 2025, 7:28 p.m.