(content: string, bits: BitArray)
| 556 | } |
| 557 | |
| 558 | public static appendAlphanumericBytes(content: string, bits: BitArray): void /*throws WriterException*/ { |
| 559 | const length = content.length; |
| 560 | let i = 0; |
| 561 | while (i < length) { |
| 562 | const code1 = Encoder.getAlphanumericCode(content.charCodeAt(i)); |
| 563 | if (code1 === -1) { |
| 564 | throw new WriterException(); |
| 565 | } |
| 566 | if (i + 1 < length) { |
| 567 | const code2 = Encoder.getAlphanumericCode(content.charCodeAt(i + 1)); |
| 568 | if (code2 === -1) { |
| 569 | throw new WriterException(); |
| 570 | } |
| 571 | // Encode two alphanumeric letters in 11 bits. |
| 572 | bits.appendBits(code1 * 45 + code2, 11); |
| 573 | i += 2; |
| 574 | } else { |
| 575 | // Encode one alphanumeric letter in six bits. |
| 576 | bits.appendBits(code1, 6); |
| 577 | i++; |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | public static append8BitBytes(content: string, bits: BitArray, encoding: string): void { |
| 583 | let bytes: Uint8Array; |
no test coverage detected