{"id":2889,"date":"2022-05-17T17:18:37","date_gmt":"2022-05-17T17:18:37","guid":{"rendered":"https:\/\/www.bardecode.com\/en1\/?p=2889"},"modified":"2022-05-17T17:18:37","modified_gmt":"2022-05-17T17:18:37","slug":"read-binary-barcode-data","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/en1\/read-binary-barcode-data\/","title":{"rendered":"How to read binary barcode data"},"content":{"rendered":"<p>Most barcodes store text information but 2-D barcodes (such as QR-Code, Datamatrix and PDF-417) can also be used to store binary data. This article explains how to get at the binary data using the Softek Barcode Reader Toolkit. 2-D barcodes don&#8217;t have any way of telling the barcode reader how they&#8217;ve been encoded so it&#8217;s not possible to automatically tell whether they represent a string (say of UTF-8 data) or binary data.<\/p>\n<p>You can access the binary data in a 2-D barcode using the <strong>GetRawBarString or GetRawBarStringBytes<\/strong> functions rather than the GetBarString function.<\/p>\n<p><strong>Important note<\/strong>: Do not change the default value of the Encoding property if you are going to use this function.<\/p>\n<p><strong>C++<\/strong><\/p>\n<p>int __stdcall mtGetRawBarString (HANDLE hBarcode, short index, LPSTR pBarCode, int length)<\/p>\n<p>Example:<\/p>\n<p>&#8230;<br \/>\nint n = mtScanBarCode(hBarcode, filePath);<br \/>\nfor (int i = 1; i &lt;= n; i++)<br \/>\n{<br \/>\nchar data[BUFSIZ];<br \/>\nint l = mtGetRawBarString(hBarcode, i, data, BUFSIZ);<br \/>\n&#8230;<br \/>\n}<\/p>\n<p><strong>C#<\/strong><\/p>\n<p>byte[] GetRawBarStringBytes(int nBarcode)<\/p>\n<p>Example:<\/p>\n<p>&#8230;<br \/>\nint n = barcode.ScanBarCode(FilePath.Text);<br \/>\nfor (int i = 1; i &lt;= nBarCode; i++)<br \/>\n{<br \/>\nbyte[] b = barcode.GetRawBarStringBytes(i);<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most barcodes store text information but 2-D barcodes (such as QR-Code, Datamatrix and PDF-417) can also be used to store binary data. This article explains how to get at the binary data using the Softek Barcode Reader Toolkit. 2-D barcodes don&#8217;t have any way of telling the barcode reader how they&#8217;ve been encoded so it&#8217;s<\/p>\n<p><a href=\"https:\/\/www.bardecode.com\/en1\/read-binary-barcode-data\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":314,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[236,18,31],"tags":[],"class_list":["post-2889","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-documentation-for-our-toolkits-and-applications","category-knowledge-base","category-software-development-kits"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/2889"}],"collection":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/comments?post=2889"}],"version-history":[{"count":1,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/2889\/revisions"}],"predecessor-version":[{"id":2890,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/2889\/revisions\/2890"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media\/314"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media?parent=2889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/categories?post=2889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/tags?post=2889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}