static void AppendAlphanumericBytes(String content, BitVector bits) {
int length = content.Length;
int i = 0;
while (i < length) {
int code1 = GetAlphanumericCode(content[i]);
if (code1 == -1) {
throw new WriterException();
}
if (i + 1 < length) {
int code2 = GetAlphanumericCode(content[i + 1]);
if (code2 == -1) {
throw new 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++;
}
}
}