本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
681B

  1. package qr
  2. import (
  3. "errors"
  4. "github.com/boombuler/barcode/utils"
  5. )
  6. func encodeUnicode(content string, ecl ErrorCorrectionLevel) (*utils.BitList, *versionInfo, error) {
  7. data := []byte(content)
  8. vi := findSmallestVersionInfo(ecl, byteMode, len(data)*8)
  9. if vi == nil {
  10. return nil, nil, errors.New("To much data to encode")
  11. }
  12. // It's not correct to add the unicode bytes to the result directly but most readers can't handle the
  13. // required ECI header...
  14. res := new(utils.BitList)
  15. res.AddBits(int(byteMode), 4)
  16. res.AddBits(len(content), vi.charCountBits(byteMode))
  17. for _, b := range data {
  18. res.AddByte(b)
  19. }
  20. addPaddingAndTerminator(res, vi)
  21. return res, vi, nil
  22. }
上海开阖软件有限公司 沪ICP备12045867号-1