barcode/qr/automatic.go

24 lines
579 B
Go
Raw Permalink Normal View History

2013-12-11 13:31:11 +00:00
package qr
import (
"fmt"
2014-08-11 08:34:45 +00:00
2025-01-03 19:41:46 +00:00
"git.bbr-dev.info/brajkovic/barcode/utils"
2013-12-11 13:31:11 +00:00
)
func encodeAuto(content string, ecl ErrorCorrectionLevel) (*utils.BitList, *versionInfo, error) {
2013-12-11 14:22:46 +00:00
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
}
bits, vi, _ = Unicode.getEncoder()(content, ecl)
if bits != nil && vi != nil {
return bits, vi, nil
}
2013-12-11 13:31:11 +00:00
return nil, nil, fmt.Errorf("No encoding found to encode \"%s\"", content)
}