1 year ago

#386003

test-img

R_Lump

Usage of the qrencoder package

I'm currently struggling with QR-Codes or better said with encoding of strings into an QR-Code.

I'm working with the following System:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

I'm using the qrencoder Package in R, which relays on the c library libqrencoder.
In the following version:

qrencoder_0.1.0 

My QR-Scanner is the Netum Scan NSL5 (https://cdn.shopify.com/s/files/1/2144/8019/files/L5_User_Mnaual.pdf?v=1644137899) and I set the standard keyboard to German. As far as I know the scanner interprets the characters with the ISO-8859-1 Codebook.

Since I needed a way to although display my QR-Codes nicely, I modified this ggqrcode function:https://github.com/GuangchuangYu/yyplot/blob/master/R/ggqrcode.R to my needs.

The use case: I have csv-files which contain strings. These Strings are encoded in UTF-8. On the bases of these files I need to create QR-Codes. These QR-Code also need to contain function keys like enter, bell, arrow down and alike. These codes then will be scanned to "auto" fill an html-form.

The Problem:

  1. I'm able to encode some function keys via the hex code information in the user manual of my scanner. Even though I need to wirte them differently: \u.. with out he appendix of h. But I can't use function keys and ISO-8859-1 characters in the same QR-Code.

  2. Sadly I haven't figured out yet how to encode the bell.

  3. Whenever I try to encode two german umlauts characters directly after one another in a QR-Code an QR-Code is created but when I try to scan it. I won't get any input.

  4. I would like to use the utf-8 mode of the qrencoder. Since I can set my scanner to the UTF-8 characterset. I already try the qrencode_raw function with the hint parameter set to two.

qrencode_raw("ÄÜda126",hint = 2)

Sadly this dosen't work and ÄÜ can't be scanned in the created QR-Code Plot.

Thanks for your help!

SampleCode:

ggqrcode <- function(text, color="black", alpha=1) {
  pkg <- "qrencoder"
  tidy <- "tidyverse"
  require(pkg, character.only = TRUE)
  require(tidy,character.only = T)
  
  x <- qrencode(text)
  x <- as.data.frame(x)
  
  y <- x
  y$id <- rownames(y)
  y <- gather(y, "key", "value", colnames(y)[-ncol(y)])
  y$key = factor(y$key, levels=rev(colnames(x)))
  y$id = factor(y$id, levels=rev(rownames(x)))
  
  ggplot(
    y,
    aes_(x=~id, y=~key)
  ) +
    geom_tile(
      aes_(fill=~value),
      alpha=alpha
    ) +
    scale_fill_gradient(
      low="white", 
      high=color
    ) +
    theme_void() + 
    theme(
      legend.position='none',
      aspect.ratio = 1
    )
}

QRcodeValues <- list(
  space = "\u20",
  arrowUp = "\u04",
  arrowDown = "\u0A",
  tab = "\u09",
  enter = "\u07"
)

problemScans <- list(
  
  problem01 = ggqrcode(
    paste0(
      "arrowDown",
      QRcodeValues$arrowDown,
      "ähm"
    )
  ),
  problem02 = ggqrcode(
    paste0(
      "bell?",
      "\u0D"
    )
  ),
  porblem03 = ggqrcode(
    paste0(
      "00",
      "ÄÜ",
      "16851as"
    )
  )
)


r

c

qr-code

0 Answers

Your Answer

Accepted video resources