2013-12-11 13:31:11 +00:00
|
|
|
package qr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2013-12-13 12:53:27 +00:00
|
|
|
"github.com/boombuler/barcode/utils"
|
2013-12-11 13:31:11 +00:00
|
|
|
)
|
|
|
|
|
2013-12-13 12:53:27 +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
|
|
|
|
}
|
2013-12-11 19:26:35 +00:00
|
|
|
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)
|
|
|
|
}
|