read_hex: Read bytes as hexadecimal strings

View source: R/read-hex.R

read_hexR Documentation

Read bytes as hexadecimal strings

Description

Read bytes as hexadecimal strings

Usage

read_hex(con, n = 1, size = 1, endian = NULL)

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 hexadecimal strings to read. Default: 1

size

size in bytes of each string. Default: 1

endian

Ordering of bytes within the file when reading multi-byte values. Possible values: 'big' or 'little'. Default: NULL indicates that endian option should be retrieved from the connection object if possible (where the user has used set_endian()) or otherwise will be set to "little"

Value

vector of hexadecimal character strings

See Also

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

Examples

con <- rawConnection(as.raw(1:4))
read_hex(con, n = 4, size = 1)
close(con)

con <- rawConnection(as.raw(1:4))
read_hex(con, n = 1, size = 4)
close(con)

con <- rawConnection(as.raw(1:4))
read_hex(con, n = 2, size = 2, endian = "big")
close(con)

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