Skip to content

Instantly share code, notes, and snippets.

@matt-dray
Last active September 9, 2021 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-dray/9197a78b6d3d0cf9caa1df0f94633f6d to your computer and use it in GitHub Desktop.
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}
# 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/")
@matt-dray
Copy link
Author

⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛
⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛
⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛
⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛
⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛
⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜
⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛
⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛
⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬛
⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜
⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜
⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛
⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬛ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬛ ⬜
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬜ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬛ ⬜
⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬜ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛
⬛ ⬜ ⬜ ⬜ ⬜ ⬜ ⬛ ⬜ ⬛ ⬜ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬜
⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬛ ⬛ ⬛ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬛ ⬜ ⬜ ⬜ ⬛ ⬜ ⬜ ⬛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment