hex2raw: Convert String Hex Representation to Raw Vector

Description Usage Arguments Details Value See Also Examples

View source: R/hex2raw.R

Description

Converts a string hexadecimal representation to a raw vector.

Usage

1
hex2raw(hex)

Arguments

hex

character string or character vector containing a hexadecimal representation.

Details

Non-hexadecimal characters are removed.

Value

A raw vector.

The return value is a list of raw vectors when the argument hex contains more than one hexadecimal representation.

See Also

raw2hex in package PKI, readWKB

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# create a character string containing a hexadecimal representation
hex <- "0101000000000000000000f03f0000000000000840"

# convert to raw vector
wkb <- hex2raw(hex)


# create a character vector containing a hexadecimal representation
hex <- c("01", "01", "00", "00", "00", "00", "00", "00", "00", "00", "00",
         "f0", "3f", "00", "00", "00", "00", "00", "00", "08", "40")

# convert to raw vector
wkb <- hex2raw(hex)


# create vector of two character strings each containing a hex representation
hex <- c("0101000000000000000000f03f0000000000000840",
         "010100000000000000000000400000000000000040")

# convert to list of two raw vectors
wkb <- hex2raw(hex)

Example output



wkb documentation built on Dec. 6, 2019, 1:06 a.m.

Related to hex2raw in wkb...