bardecode.com
barcode reading software
  • Home
  • Download
  • Purchase
  • SDK Licensing
  • Pricing
    • Windows SDK Price List
    • Windows SDK with PDF Extension Price List
    • Linux SDK Price List
    • Linux SDK with PDF Extension Price List
    • PDF Extension For Windows Price List
    • Multi-Platform Toolkit for .NET Price List
    • BardecodeFiler Desktop Only Price List
    • BardecodeFiler Windows Service Price List
    • DOS Command Prompt Barcode Tool Price List
    • Terms and Conditions
    • Refund Policy
  • Products
    • Softek Barcode Reader Toolkit for Windows
    • Softek Barcode Reader Toolkit for Linux
    • BardecodeFiler Desktop App
    • BardecodeFiler Windows Service
    • Windows DOS Command Prompt Tool
    • Multi-platform barcode reader toolkit for .NET
    • Aquaforest’s Autobahn DX
  • Knowledge Base
    • Documentation
    • Specifications
  • News
  • Contact
    • About Us
    • Terms and Conditions
    • Resellers
    • Links
Select Page ...

News

Reading binary data from a barcode using Visual C#

admin April 8, 2019 Documentation, Knowledge Base, Software Development Kits

If you are handling binary data in barcodes such as you find in some 2-D barcodes (PDF417, QrCode or DataMatrix) then the following method will allow you to create a byte array that contains the original binary data from the barcode – including all the null and 8-bit values.

1. Using Quoted printable Encoding

barcode.Encoding = 1;

This will return the barcode value using either printable characters or =XX where XX is a hex value for non-printable characters (e.g for null you get =00). By default the data will be potentially be handled as if it contains utf-8 encoded data.

2. Convert the quoted printable output from GetBarString to a byte array using the following function:

private byte[] convertQPToByteArray(string qpString) { // Assess how many bytes required int c = 0; for (int i = 0; i < qpString.Length; i++, c++) if (qpString[i] == '=') i += 2; byte[] binaryData = new byte[c]; int zero = Convert.ToInt16('0'); c = 0; for (int i = 0; i < qpString.Length; i++, c++) { if (qpString[i] == '=') { binaryData[c] = (byte) int.Parse(qpString.Substring(i + 1, 2), System.Globalization.NumberStyles.HexNumber); i += 2; } else { binaryData[c] = Convert.ToByte(qpString[i]); } } return binaryData; }
← Calling the Linux C Library from C++ code
Softek Barcode Reader Toolkit for Windows Version 8.3.3.3 has been released →
admin

  • Copyright © 2023 Softek Software Ltd. All Rights Reserved