MCPcopy
hub / github.com/skip2/go-qrcode / newDataEncoder

Function newDataEncoder

encoder.go:118–160  ·  view source on GitHub ↗

newDataEncoder constructs a dataEncoder.

(t dataEncoderType)

Source from the content-addressed store, hash-verified

116
117// newDataEncoder constructs a dataEncoder.
118func newDataEncoder(t dataEncoderType) *dataEncoder {
119 d := &dataEncoder{}
120
121 switch t {
122 case dataEncoderType1To9:
123 d = &dataEncoder{
124 minVersion: 1,
125 maxVersion: 9,
126 numericModeIndicator: bitset.New(b0, b0, b0, b1),
127 alphanumericModeIndicator: bitset.New(b0, b0, b1, b0),
128 byteModeIndicator: bitset.New(b0, b1, b0, b0),
129 numNumericCharCountBits: 10,
130 numAlphanumericCharCountBits: 9,
131 numByteCharCountBits: 8,
132 }
133 case dataEncoderType10To26:
134 d = &dataEncoder{
135 minVersion: 10,
136 maxVersion: 26,
137 numericModeIndicator: bitset.New(b0, b0, b0, b1),
138 alphanumericModeIndicator: bitset.New(b0, b0, b1, b0),
139 byteModeIndicator: bitset.New(b0, b1, b0, b0),
140 numNumericCharCountBits: 12,
141 numAlphanumericCharCountBits: 11,
142 numByteCharCountBits: 16,
143 }
144 case dataEncoderType27To40:
145 d = &dataEncoder{
146 minVersion: 27,
147 maxVersion: 40,
148 numericModeIndicator: bitset.New(b0, b0, b0, b1),
149 alphanumericModeIndicator: bitset.New(b0, b0, b1, b0),
150 byteModeIndicator: bitset.New(b0, b1, b0, b0),
151 numNumericCharCountBits: 14,
152 numAlphanumericCharCountBits: 13,
153 numByteCharCountBits: 16,
154 }
155 default:
156 log.Panic("Unknown dataEncoderType")
157 }
158
159 return d
160}
161
162// encode data as one or more segments and return the encoded data.
163//

Callers 6

NewFunction · 0.85
NewWithForcedVersionFunction · 0.85
TestClassifyDataModeFunction · 0.85
TestSingleModeEncodingsFunction · 0.85
TestOptimiseEncodingFunction · 0.85

Calls 1

NewFunction · 0.92

Tested by 4

TestClassifyDataModeFunction · 0.68
TestSingleModeEncodingsFunction · 0.68
TestOptimiseEncodingFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…