Last active
September 9, 2021 20:40
-
-
Save matt-dray/9197a78b6d3d0cf9caa1df0f94633f6d to your computer and use it in GitHub Desktop.
R function that creates a QR code and can convert it to unicode, including emoji, thanks to {qrcode}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See also Terence Eden | |
# https://shkspr.mobi/blog/2020/12/a-qr-code-built-from-emoji/ | |
install.packages("qrcode") # if not already installed | |
qr2uni <- function(string, # string to encode | |
uni_0 = "\U2B1C", # large white square emoji | |
uni_1 = "\U2B1B", # large black square emoji | |
plot = FALSE # plot image of the QR too | |
) { | |
qr_mat <- qrcode::qrcode_gen( | |
string, | |
dataOutput = TRUE, | |
plotQRcode = plot | |
) | |
y <- gsub(0, uni_0, qr_mat) | |
z <- gsub(1, uni_1, y) | |
m <- matrix(z, nrow = sqrt(length(z)), ncol = sqrt(length(z))) | |
for (i in 1:nrow(m)) { | |
cat(m[i, ], "\n") | |
} | |
} | |
qr2uni("https://www.rostrum.blog/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛
⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛
⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛
⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛
⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜
⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛
⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛
⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛
⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜
⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜
⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛
⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬜
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜
⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛