package qr

import "github.com/boombuler/barcode/qr"

Package qr can be used to create QR barcodes.

Index

Examples

Functions

func Encode

func Encode(content string, level ErrorCorrectionLevel, mode Encoding) (barcode.Barcode, error)

Encode returns a QR barcode with the given content, error correction level and uses the given encoding

Example

Code:

{
	f, _ := os.Create("qrcode.png")
	defer f.Close()

	qrcode, err := Encode("hello world", L, Auto)
	if err != nil {
		fmt.Println(err)
	} else {
		qrcode, err = barcode.Scale(qrcode, 100, 100)
		if err != nil {
			fmt.Println(err)
		} else {
			png.Encode(f, qrcode)
		}
	}
}

Types

type Encoding

type Encoding byte

Encoding mode for QR Codes.

const (
	// Auto will choose ths best matching encoding
	Auto Encoding = iota
	// Numeric encoding only encodes numbers [0-9]
	Numeric
	// AlphaNumeric encoding only encodes uppercase letters, numbers and  [Space], $, %, *, +, -, ., /, :
	AlphaNumeric
	// Unicode encoding encodes the string as utf-8
	Unicode
)

func (Encoding) String

func (e Encoding) String() string

type ErrorCorrectionLevel

type ErrorCorrectionLevel byte

ErrorCorrectionLevel indicates the amount of "backup data" stored in the QR code

const (
	// L recovers 7% of data
	L ErrorCorrectionLevel = iota
	// M recovers 15% of data
	M
	// Q recovers 25% of data
	Q
	// H recovers 30% of data
	H
)

func (ErrorCorrectionLevel) String

func (ecl ErrorCorrectionLevel) String() string

Source Files

alphanumeric.go automatic.go blocks.go encoder.go errorcorrection.go numeric.go qrcode.go unicode.go versioninfo.go

Version
v1.0.1
Published
Feb 19, 2019
Platform
darwin/amd64
Imports
9 packages
Last checked
4 minutes ago

Tools for package owners.