bencoder.go 453 B

123456789101112131415161718192021
  1. package code128
  2. import (
  3. "github.com/boombuler/barcode/utils"
  4. "strings"
  5. )
  6. const bTable = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  7. func encodeBTable(content []rune) *utils.BitList {
  8. result := new(utils.BitList)
  9. result.AddByte(startBSymbol)
  10. for _, r := range content {
  11. idx := strings.IndexRune(bTable, r)
  12. if idx < 0 {
  13. return nil
  14. }
  15. result.AddByte(byte(idx))
  16. }
  17. return result
  18. }