MCPcopy Create free account
hub / github.com/boombuler/barcode / EncodeWithoutChecksumWithColor

Function EncodeWithoutChecksumWithColor

code128/encode.go:195–212  ·  view source on GitHub ↗
(content string, color barcode.ColorScheme)

Source from the content-addressed store, hash-verified

193}
194
195func EncodeWithoutChecksumWithColor(content string, color barcode.ColorScheme) (barcode.Barcode, error) {
196 contentRunes := strToRunes(content)
197 if len(contentRunes) <= 0 || len(contentRunes) > 80 {
198 return nil, fmt.Errorf("content length should be between 1 and 80 runes but got %d", len(contentRunes))
199 }
200 idxList := getCodeIndexList(contentRunes)
201
202 if idxList == nil {
203 return nil, fmt.Errorf("\"%s\" could not be encoded", content)
204 }
205
206 result := new(utils.BitList)
207 for _, idx := range idxList.GetBytes() {
208 result.AddBit(encodingTable[idx]...)
209 }
210 result.AddBit(encodingTable[stopSymbol]...)
211 return utils.New1DCodeWithColor(barcode.TypeCode128, content, result, color), nil
212}

Callers 1

EncodeWithoutChecksumFunction · 0.85

Calls 5

New1DCodeWithColorFunction · 0.92
strToRunesFunction · 0.85
getCodeIndexListFunction · 0.85
GetBytesMethod · 0.80
AddBitMethod · 0.80

Tested by

no test coverage detected