pablohirafuji/elm-qrcode/3.1.1

NOTE: the latest version is 4.0.3

QRCode

QR Code encoding and rendering.

type QRCode

QRCode type.

= Low
| Medium
| Quartile
| High

Error correction level. Provides the following error correction capability:

  • Low: 7% of codewords can be restored.
  • Medium: 15% of codewords can be restored.
  • Quartile: 25% of codewords can be restored.
  • High: 30% of codewords can be restored.

Encoding

encode : String -> Result Error QRCode

Transform a string into a result Error or a QRCode using Quartile ErrorCorrection.

encodeWith : ErrorCorrection -> String -> Result Error QRCode

Transform a string with a given ErrorCorrection into a result Error or a QRCode.

Rendering

toSvg : QRCode -> Html msg

Transform a QRCode into a svg element.

qrCodeView : String -> Html msg
qrCodeView message =
    QRCode.encode message
        |> Result.map QRCode.toSvg
        |> Result.withDefault
            (Html.text "Error while encoding to QRCode.")

Tip: You can determine the size of the generated svg setting width and height styles.

Same as toSvg, but without the quiet zone.

toString : QRCode -> String

Transform a QRCode into a string.

"Hello World!"
    |> QRCode.encode
    |> Result.map QRCode.toString
    |> Result.withDefault "Error while encoding to QRCode."

Returns:

■■■■■■■ ■■■■  ■■■■■■■
■     ■ ■■■■  ■     ■
■ ■■■ ■ ■■■■■ ■ ■■■ ■
■ ■■■ ■ ■   ■ ■ ■■■ ■
■ ■■■ ■ ■■■■  ■ ■■■ ■
■     ■    ■  ■     ■
■■■■■■■ ■ ■ ■ ■■■■■■■
        ■ ■■
 ■■ ■ ■■  ■   ■ ■■■■■
■■ ■■■   ■■■■ ■■■  ■■
 ■ ■■ ■■ ■■■■■ ■■■■■■
 ■■      ■■■■   ■  ■
■  ■ ■■■  ■■■■ ■■
        ■■ ■■■    ■■
■■■■■■■ ■ ■    ■■ ■■■
■     ■  ■  ■  ■    ■
■ ■■■ ■ ■■■     ■
■ ■■■ ■   ■■  ■■■ ■■
■ ■■■ ■ ■ ■ ■ ■ ■ ■ ■
■     ■ ■  ■    ■  ■
■■■■■■■   ■■■  ■   ■■

Error

type Error
= AlignmentPatternNotFound
| InvalidNumericChar
| InvalidAlphanumericChar
| InvalidUTF8Char
| LogTableException Int
| PolynomialMultiplyException
| PolynomialModException
| InputLengthOverflow

Possible enconding errors.