automatic.go 573 B

123456789101112131415161718192021222324
  1. package qr
  2. import (
  3. "fmt"
  4. "github.com/boombuler/barcode/utils"
  5. )
  6. func encodeAuto(content string, ecl ErrorCorrectionLevel) (*utils.BitList, *versionInfo, error) {
  7. bits, vi, _ := Numeric.getEncoder()(content, ecl)
  8. if bits != nil && vi != nil {
  9. return bits, vi, nil
  10. }
  11. bits, vi, _ = AlphaNumeric.getEncoder()(content, ecl)
  12. if bits != nil && vi != nil {
  13. return bits, vi, nil
  14. }
  15. bits, vi, _ = Unicode.getEncoder()(content, ecl)
  16. if bits != nil && vi != nil {
  17. return bits, vi, nil
  18. }
  19. return nil, nil, fmt.Errorf("No encoding found to encode \"%s\"", content)
  20. }