barcode/qr/automatic.go

20 lines
462 B
Go
Raw Normal View History

2013-12-11 13:31:11 +00:00
package qr
import (
"fmt"
"github.com/boombuler/barcode"
)
2013-12-11 14:22:46 +00:00
func encodeAuto(content string, ecl ErrorCorrectionLevel) (*barcode.BitList, *versionInfo, error) {
bits, vi, _ := Numeric.getEncoder()(content, ecl)
2013-12-11 13:31:11 +00:00
if bits != nil && vi != nil {
return bits, vi, nil
}
2013-12-11 14:22:46 +00:00
bits, vi, _ = AlphaNumeric.getEncoder()(content, ecl)
2013-12-11 13:31:11 +00:00
if bits != nil && vi != nil {
return bits, vi, nil
}
return nil, nil, fmt.Errorf("No encoding found to encode \"%s\"", content)
}