| 79 | |
| 80 | |
| 81 | qrcodegen::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 | |
| 104 | std::vector<qrcodegen::QrSegment> qrcodegen::QrSegment::makeSegments(const char *text) { |
nothing calls this directly
no test coverage detected