MCPcopy
hub / github.com/zxing-js/library / appendAlphanumericBytes

Method appendAlphanumericBytes

src/core/qrcode/encoder/Encoder.ts:558–580  ·  view source on GitHub ↗
(content: string, bits: BitArray)

Source from the content-addressed store, hash-verified

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;

Callers 2

appendBytesMethod · 0.80
Encoder.spec.tsFile · 0.80

Calls 2

getAlphanumericCodeMethod · 0.80
appendBitsMethod · 0.80

Tested by

no test coverage detected