appendNumericBytes static method
void
appendNumericBytes(
- String content,
- BitArray bits
)
Implementation
static void appendNumericBytes(String content, BitArray bits) {
var length = content.length;
var i = 0;
while (i < length) {
var num1 = content.codeUnitAt(i) - $0;
if (i + 2 < length) {
// Encode three numeric letters in ten bits.
var num2 = content.codeUnitAt(i + 1) - $0;
var num3 = content.codeUnitAt(i + 2) - $0;
bits.appendBits(num1 * 100 + num2 * 10 + num3, 10);
i += 3;
} else if (i + 1 < length) {
// Encode two numeric letters in seven bits.
var num2 = content.codeUnitAt(i + 1) - $0;
bits.appendBits(num1 * 10 + num2, 7);
i += 2;
} else {
// Encode one numeric letter in four bits.
bits.appendBits(num1, 4);
i++;
}
}
}