Learn R Programming

ctypesio (version 0.1.2)

read_hex: Read bytes as hexadecimal strings

Description

Read bytes as hexadecimal strings

Usage

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

Value

vector of hexadecimal character strings

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"

See Also

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

Examples

Run this code
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)

Run the code above in your browser using DataLab