automatic.go 573 B

1234567891011121314151617181920212223
  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. }