Skip to content

Commit

Permalink
Merge pull request davidshimjs#12 from taku0/unicode_corruption_bug
Browse files Browse the repository at this point in the history
Fixed Unicode corruption bug
  • Loading branch information
davidshimjs committed Oct 13, 2013
2 parents 06c7a5e + 0f73d48 commit 51abe31
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ var QRCode;
this.mode = QRMode.MODE_8BIT_BYTE;
this.data = data;
this.parsedData = [];
var byteArray = [];

// Added to support UTF-8 Characters
for (var i = 0, l = this.data.length; i < l; i++) {
var byteArray = [];
var code = this.data.charCodeAt(i);

if (code > 0x10000) {
Expand All @@ -52,9 +52,11 @@ var QRCode;
byteArray[0] = code;
}

this.parsedData = this.parsedData.concat(byteArray);
this.parsedData.push(byteArray);
}

this.parsedData = Array.prototype.concat.apply([], this.parsedData);

if (this.parsedData.length != this.data.length) {
this.parsedData.unshift(191);
this.parsedData.unshift(187);
Expand Down

0 comments on commit 51abe31

Please sign in to comment.