mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 09:11:53 -05:00
24 lines
573 B
Go
24 lines
573 B
Go
|
package qr
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/boombuler/barcode/utils"
|
||
|
)
|
||
|
|
||
|
func encodeAuto(content string, ecl ErrorCorrectionLevel) (*utils.BitList, *versionInfo, error) {
|
||
|
bits, vi, _ := Numeric.getEncoder()(content, ecl)
|
||
|
if bits != nil && vi != nil {
|
||
|
return bits, vi, nil
|
||
|
}
|
||
|
bits, vi, _ = AlphaNumeric.getEncoder()(content, ecl)
|
||
|
if bits != nil && vi != nil {
|
||
|
return bits, vi, nil
|
||
|
}
|
||
|
bits, vi, _ = Unicode.getEncoder()(content, ecl)
|
||
|
if bits != nil && vi != nil {
|
||
|
return bits, vi, nil
|
||
|
}
|
||
|
return nil, nil, fmt.Errorf("No encoding found to encode \"%s\"", content)
|
||
|
}
|