sxtMap: sxtMap

Description Usage Arguments Value Description Base64 Author(s) Examples

View source: R/sxtMap.R

Description

sxtMap maps 6-character bit patterns to their corresponding Base64 characters (an "sextet"), or characters back to bit patterns.

Usage

1
sxtMap(x)

Arguments

x

(character or numeric) A vector of encoding characters, bit-patterns or indices. Note: indices are vector indices, not interpreted bit-patterns, i.e sxtMap("000000") == sxtMap(1)

Value

(character) A vector of Base 64 characters or their corresponding bit-patterns.

Description

If the input is a vector of 6-character bit patterns, sxtMap returns the corresponding character from the Base64 binary-to-text encoding. If the input is a vector of 1-character strings sxtMap returns the corresponding bit pattern. If the input is numeric, it is interpreted as indices into the sxt vector. The returned vector has the same length as the input but no checking for valid input is done.

Base64

Base64 is a binary to text encoding specified in RFC 1738; we use the URL and filename-safe alphabet version with the following encoding from 000000 to 111111: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" This is safe for most applications; one exception is Microsoft Excel where strings that begin with a "-" are silently convert to formulas. (QQIDs are not affected by this problem since they always begin with a lowercase alphabetic character.)

Author(s)

(c) 2019 Boris Steipe, licensed under MIT (see file LICENSE in this package).

Examples

1
2
3
4
5
6
7
8
# sxtMap three bit patterns
sxtMap(c("101101", "011011", "010110"))   # "t"    "b"    "W"

# sxtMap three encoding characters
sxtMap(c("a", "b", "c"))  # "011010" "011011" "011100"

# print the entire r64 vector as one string
paste0(sxtMap(1:64), collapse = "")

qqid documentation built on May 2, 2019, 12:19 p.m.