MCPcopy
hub / github.com/davidshimjs/qrcodejs / QR8bitByte

Function QR8bitByte

qrcode.js:29–65  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

27 //
28 //---------------------------------------------------------------------
29 function QR8bitByte(data) {
30 this.mode = QRMode.MODE_8BIT_BYTE;
31 this.data = data;
32 this.parsedData = [];
33
34 // Added to support UTF-8 Characters
35 for (var i = 0, l = this.data.length; i < l; i++) {
36 var byteArray = [];
37 var code = this.data.charCodeAt(i);
38
39 if (code > 0x10000) {
40 byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);
41 byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);
42 byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);
43 byteArray[3] = 0x80 | (code & 0x3F);
44 } else if (code > 0x800) {
45 byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);
46 byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);
47 byteArray[2] = 0x80 | (code & 0x3F);
48 } else if (code > 0x80) {
49 byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);
50 byteArray[1] = 0x80 | (code & 0x3F);
51 } else {
52 byteArray[0] = code;
53 }
54
55 this.parsedData.push(byteArray);
56 }
57
58 this.parsedData = Array.prototype.concat.apply([], this.parsedData);
59
60 if (this.parsedData.length != this.data.length) {
61 this.parsedData.unshift(191);
62 this.parsedData.unshift(187);
63 this.parsedData.unshift(239);
64 }
65 }
66
67 QR8bitByte.prototype = {
68 getLength: function (buffer) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected