Encode creates a codabar barcode for the given content and color scheme
(content string, color barcode.ColorScheme)
| 34 | |
| 35 | // Encode creates a codabar barcode for the given content and color scheme |
| 36 | func EncodeWithColor(content string, color barcode.ColorScheme) (barcode.Barcode, error) { |
| 37 | checkValid, _ := regexp.Compile(`[ABCD][0123456789\-\$\:/\.\+]*[ABCD]$`) |
| 38 | if content == "!" || checkValid.ReplaceAllString(content, "!") != "!" { |
| 39 | return nil, fmt.Errorf("can not encode \"%s\"", content) |
| 40 | } |
| 41 | resBits := new(utils.BitList) |
| 42 | for i, r := range content { |
| 43 | if i > 0 { |
| 44 | resBits.AddBit(false) |
| 45 | } |
| 46 | resBits.AddBit(encodingTable[r]...) |
| 47 | } |
| 48 | return utils.New1DCodeWithColor(barcode.TypeCodabar, content, resBits, color), nil |
| 49 | } |
| 50 | |
| 51 | // Encode creates a codabar barcode for the given content |
| 52 | func Encode(content string) (barcode.Barcode, error) { |
no test coverage detected