Skip to content

Commit 8548019

Browse files
committed
Added support file to encode qrcode in UTF8 format.
1 parent dceec14 commit 8548019

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

js/qrcode_UTF8.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//---------------------------------------------------------------------
22
//
3-
// QR Code Generator for JavaScript SJIS Support (optional)
3+
// QR Code Generator for JavaScript UTF8 Support (optional)
44
//
55
// Copyright (c) 2011 Kazuhiko Arase
66
//
@@ -20,6 +20,7 @@
2020
//---------------------------------------------------------------------
2121
// overwrite qrcode.stringToBytes
2222
//---------------------------------------------------------------------
23+
2324
qrcode.stringToBytes = function(s) {
2425
// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
2526
function toUTF8Array(str) {
@@ -43,7 +44,7 @@
4344
// subtracting 0x10000 and splitting the
4445
// 20 bits of 0x0-0xFFFFF into two halves
4546
charcode = 0x10000 + (((charcode & 0x3ff)<<10)
46-
| (str.charCodeAt(i) & 0x3ff))
47+
| (str.charCodeAt(i) & 0x3ff));
4748
utf8.push(0xf0 | (charcode >>18),
4849
0x80 | ((charcode>>12) & 0x3f),
4950
0x80 | ((charcode>>6) & 0x3f),
@@ -54,5 +55,5 @@
5455
}
5556
return toUTF8Array(s);
5657
};
57-
58+
5859
}(qrcode);

0 commit comments

Comments
 (0)