git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/barcode/qr/automatic.go (about) 1 package qr 2 3 import ( 4 "fmt" 5 6 "git.sr.ht/~pingoo/stdx/barcode/utils" 7 ) 8 9 func encodeAuto(content string, ecl ErrorCorrectionLevel) (*utils.BitList, *versionInfo, error) { 10 bits, vi, _ := Numeric.getEncoder()(content, ecl) 11 if bits != nil && vi != nil { 12 return bits, vi, nil 13 } 14 bits, vi, _ = AlphaNumeric.getEncoder()(content, ecl) 15 if bits != nil && vi != nil { 16 return bits, vi, nil 17 } 18 bits, vi, _ = Unicode.getEncoder()(content, ecl) 19 if bits != nil && vi != nil { 20 return bits, vi, nil 21 } 22 return nil, nil, fmt.Errorf("No encoding found to encode \"%s\"", content) 23 }