...

Source file src/github.com/boombuler/barcode/qr/unicode.go

Documentation: github.com/boombuler/barcode/qr

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

View as plain text