MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / makeAlphanumeric

Method makeAlphanumeric

Libraries/QRCode/tests/QrSegment.cpp:81–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81qrcodegen::QrSegment qrcodegen::QrSegment::makeAlphanumeric(const char *text) {
82 BitBuffer bb;
83 int accumData = 0;
84 int accumCount = 0;
85 int charCount = 0;
86 for (; *text != '\0'; text++, charCount++) {
87 char c = *text;
88 if (c < ' ' || c > 'Z')
89 throw "String contains unencodable characters in alphanumeric mode";
90 accumData = accumData * 45 + ALPHANUMERIC_ENCODING_TABLE[c - ' '];
91 accumCount++;
92 if (accumCount == 2) {
93 bb.appendBits(accumData, 11);
94 accumData = 0;
95 accumCount = 0;
96 }
97 }
98 if (accumCount > 0) // 1 character remaining
99 bb.appendBits(accumData, 6);
100 return QrSegment(Mode::ALPHANUMERIC, charCount, bb.getBytes(), bb.getBitLength());
101}
102
103
104std::vector<qrcodegen::QrSegment> qrcodegen::QrSegment::makeSegments(const char *text) {

Callers

nothing calls this directly

Calls 4

QrSegmentClass · 0.85
appendBitsMethod · 0.80
getBytesMethod · 0.80
getBitLengthMethod · 0.80

Tested by

no test coverage detected