appendAlphanumericBytes static method
void
appendAlphanumericBytes(
- String content,
- BitArray bits
)
Implementation
static void appendAlphanumericBytes(String content, BitArray bits) {
var length = content.length;
var i = 0;
while (i < length) {
var code1 = getAlphanumericCode(content.codeUnitAt(i));
if (code1 == -1) {
throw WriterException('');
}
if (i + 1 < length) {
var code2 = getAlphanumericCode(content.codeUnitAt(i + 1));
if (code2 == -1) {
throw WriterException('');
}
// Encode two alphanumeric letters in 11 bits.
bits.appendBits(code1 * 45 + code2, 11);
i += 2;
} else {
// Encode one alphanumeric letter in six bits.
bits.appendBits(code1, 6);
i++;
}
}
}