{"action":"created","issue":{"url":"https://api.github.com/repos/metafloor/bwip-js/issues/59","repository_url":"https://api.github.com/repos/metafloor/bwip-js","labels_url":"https://api.github.com/repos/metafloor/bwip-js/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/metafloor/bwip-js/issues/59/comments","events_url":"https://api.github.com/repos/metafloor/bwip-js/issues/59/events","html_url":"https://github.com/metafloor/bwip-js/issues/59","id":200815167,"number":59,"title":"Aztec Code Binary Data","user":{"login":"Fujnky","id":293544,"avatar_url":"https://avatars.githubusercontent.com/u/293544?v=3","gravatar_id":"","url":"https://api.github.com/users/Fujnky","html_url":"https://github.com/Fujnky","followers_url":"https://api.github.com/users/Fujnky/followers","following_url":"https://api.github.com/users/Fujnky/following{/other_user}","gists_url":"https://api.github.com/users/Fujnky/gists{/gist_id}","starred_url":"https://api.github.com/users/Fujnky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fujnky/subscriptions","organizations_url":"https://api.github.com/users/Fujnky/orgs","repos_url":"https://api.github.com/users/Fujnky/repos","events_url":"https://api.github.com/users/Fujnky/events{/privacy}","received_events_url":"https://api.github.com/users/Fujnky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-01-14T16:51:32Z","updated_at":"2017-01-17T09:57:51Z","closed_at":null,"body":"Hello, I'm trying to encode binary data in an Aztec 2D code. Currently my code looks like that: \r\n\r\n```javascript\r\ndata = fs.readFileSync('file.bin').toString('latin1')\r\nbwipjs.toBuffer({\r\n    bcid: 'azteccode',\r\n    text: data\r\n}, function (err, png) {\r\n    if (err) {\r\n        console.log(err);\r\n    } else {\r\n        fs.writeFileSync('code.png', png, 'binary')\r\n    }\r\n});\r\n```\r\n\r\nwhich produces exactly the same result as encoding the bytes with `^NNN` and the `parse` option. My problem is, that the decoded data is different from the original data:\r\n\r\n```\r\n$ hexdump file.bin\r\n0000000 4430 2002 a642 6a4d 5340 28ca 12ca 0ef7\r\n0000010 84c7 24c6 f781 4baf b66e 0b4b 8df9 2d50\r\n0000020 cf99 b8f2 2002 0a34 ee56 7ba0 264d 4279\r\n0000030 55fd d7a7 5bca 407a 276c 2080 b11d 3a92\r\n0000040 1dbe e04a 510b                         \r\n0000046\r\n```\r\n\r\nopposed to\r\n\r\n```\r\n$ hexdump file2.bin\r\n0000000 4430 2002 c242 4da6 406a c353 288a 8ac3\r\n0000010 c312 0eb7 87c3 84c2 86c3 c224 c381 c2b7\r\n0000020 4baf c26e 4bb6 c30b c2b9 508d c22d c399\r\n0000030 c38f c2b2 02b8 3420 560a aec3 a0c2 4d7b\r\n0000040 7926 c342 55bd a7c2 97c3 8ac3 7a5b 6c40\r\n0000050 c227 2080 c21d c2b1 3a92 bec2 4a1d a0c3\r\n0000060 510b 000a                              \r\n0000063\r\n```\r\n\r\nApparently encoding it as `latin1` changes the data, but I don't know how or whether I can \"convert it back\". Is there any better method of putting binary data in the code?\r\nThank you very much."},"comment":{"url":"https://api.github.com/repos/metafloor/bwip-js/issues/comments/273075564","html_url":"https://github.com/metafloor/bwip-js/issues/59#issuecomment-273075564","issue_url":"https://api.github.com/repos/metafloor/bwip-js/issues/59","id":273075564,"user":{"login":"terryburton","id":43213,"avatar_url":"https://avatars.githubusercontent.com/u/43213?v=3","gravatar_id":"","url":"https://api.github.com/users/terryburton","html_url":"https://github.com/terryburton","followers_url":"https://api.github.com/users/terryburton/followers","following_url":"https://api.github.com/users/terryburton/following{/other_user}","gists_url":"https://api.github.com/users/terryburton/gists{/gist_id}","starred_url":"https://api.github.com/users/terryburton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terryburton/subscriptions","organizations_url":"https://api.github.com/users/terryburton/orgs","repos_url":"https://api.github.com/users/terryburton/repos","events_url":"https://api.github.com/users/terryburton/events{/privacy}","received_events_url":"https://api.github.com/users/terryburton/received_events","type":"User","site_admin":false},"created_at":"2017-01-17T09:57:51Z","updated_at":"2017-01-17T09:57:51Z","body":"A very brief look reveals that calling BWIPP as follows:\r\n\r\n    0 0 moveto (^128^128^128) (parse) /azteccode /uk.co.terryburton.bwipp findresource exec\r\n\r\nResults in the following internal bitstream sequence:\r\n\r\n    (11111) (00011) (10000000) (10000000) (10000000)\r\n\r\nWhich represents:\r\n\r\n    {Binary shift} {length 3} {128} {128} {128}\r\n\r\nSo it seems that BWIPP/BWIP-JS are generating a correct symbol.\r\n\r\nI note that `c280` is the hex UTF-8 encoding of a \"raw 128 byte\" (technically the first character of the Latin-1 suppliment): http://www.fileformat.info/info/unicode/char/0080/index.htm\r\n\r\nTherefore I think that your aim should be to tell ZXing to provide output in the form of a byte array rather than a UTF-8 encoded string. Why this should be different between Aztec Code and other format is a mystery... or a bug ;-)"}}
{"actor":{"display_login":"terryburton"}}