added EncodeWithoutChecksum for code 128 as mentioned in #16

This commit is contained in:
boombuler 2017-04-03 20:34:37 +02:00
parent 3f99eafe23
commit 0dc17c9053
1 changed files with 19 additions and 0 deletions

View File

@ -182,3 +182,22 @@ func Encode(content string) (barcode.BarcodeIntCS, error) {
result.AddBit(encodingTable[stopSymbol]...) result.AddBit(encodingTable[stopSymbol]...)
return utils.New1DCodeIntCheckSum("Code 128", content, result, sum), nil return utils.New1DCodeIntCheckSum("Code 128", content, result, sum), nil
} }
func EncodeWithoutChecksum(content string) (barcode.Barcode, error) {
contentRunes := strToRunes(content)
if len(contentRunes) <= 0 || len(contentRunes) > 80 {
return nil, fmt.Errorf("content length should be between 1 and 80 runes but got %d", len(contentRunes))
}
idxList := getCodeIndexList(contentRunes)
if idxList == nil {
return nil, fmt.Errorf("\"%s\" could not be encoded", content)
}
result := new(utils.BitList)
for _, idx := range idxList.GetBytes() {
result.AddBit(encodingTable[idx]...)
}
result.AddBit(encodingTable[stopSymbol]...)
return utils.New1DCode("Code 128", content, result), nil
}