QR code encoder.
ISO/IEC 18004:2015. QR Code bar code symbology specification.
module Matrix : sig ... end
QR 2D matrices.
The type for QR code error correction levels. Four levels respectively allowing 7%, 15%, 25% and 30% recovery of the QR code.
module Gf_256 : sig ... end
Arithmetic over galois field GF(28).
module Prop : sig ... end
QR code properties.
val encode : ?mask:int -> ?version:version -> ?mode:mode -> ?ec_level:ec_level -> string -> Matrix.t option
encode ~version ~mode ~ec_level data is a QR matrix encoding bytes
ec_level, the error correction level, defaults to
version, the version of the QR code. If unspecified the minimal needed version for the given
modeis the encoding mode. If unspecified it is guessed, but guess what, only
`Bytemode is supported.
maskcan be used to force the data mask. This should not be used, the best mask to please your scanner is automatically selected as mandated by the standard.
None is returned if
data is too large to be fit the specified QR code parameters. Use
Prop.mode_capacity to find data capacity for given QR code properties beforehand.
Note. Sometimes once the
ec_level constraints are satisfied for
data we can fit the data in a higher
ec_level with the same
version (i.e. same matrix width). In that case that higher error correction level is used instead of the given or default
- Only the (universal) byte mode data encoding is supported. This may mean larger QR codes if you are trying to encode only decimal digits, only decimal digits and uppercase US-ASCII letters or only Kanji characters.
- For textual data, using UTF-8 with
`Bytesshould work reasonably well. The module does not implement the ECI scheme to specify the encoding. Signals from the interwebs seem to indicate it's better to let scanners auto-discover the encoding as some do not understand the ECI scheme.
- Structured append, i.e. data represented by up to 16 linked QR codes, is not supported – who does ?
The following generates a QR code matrix for the given
data bytes and outputs it as an SVG image on
let output_svg_qr data = match Qrc.encode data with | None -> prerr_endline "Data capacity exceeded!" | Some m -> print_endline (Qrc.Matrix.to_svg m)