set_endian: Tag a connection with the preferred endianness

View source: R/connection-config.R

set_endianR Documentation

Tag a connection with the preferred endianness

Description

Tag a connection with the preferred endianness

Usage

set_endian(con, endian = "little")

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.

endian

Default endianness to assign to this connection. One of either "little" or "big". Default: "little". This default may be over-ridden by specifying the endian argument when calling individual functions.

Value

Modified connection object

See Also

Other connection configuration functions: set_bounds_check(), set_eof_check(), set_integer_promotion(), set_na_check()

Examples

# Open a connection and configure it so all subsequent read/write operations
# use big-endian ordering.
con <- rawConnection(as.raw(c(0, 1, 0, 1)), "rb")
con <- set_endian(con, endian = "big")

# Future reads will be be big endian
read_uint16(con, n = 1)

# Unless over-ridden during the read
read_uint16(con, n = 1, endian = "little")

close(con)


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