If a barcode contains binary data, how would I be able to read the data using the Scanner's DataEvent?
When I read from ScanDataLabel, I get extra 0s between data bytes in some parts of the array while the others seem to be untouched. I have tried encoding them to ASCII and Unicode to no avail.
I am using a Honeywell 1900 handheld barcode scanner for this application.
Below is the code that I attempted:
static void Main(string[] args)
{
var explore = new PosExplorer();
var devices = explore.GetDevices(DeviceType.Scanner);
var device = explore.GetDevice(DeviceType.Scanner, "POSScanner");
var scan = (Scanner)explore.CreateInstance(device);
scan.Open();
scan.Claim(500);
scan.DeviceEnabled = true;
scan.DataEventEnabled = true;
scan.DecodeData = true;
scan.DataEvent += delegate (object sender, DataEventArgs e){
var data = scan.ScanDataLabel;
var type = scan.ScanDataType.ToString();
var encoder = Encoding.Unicode;
var dataString = encoder.GetString(data);
var rawData = Encoding.ASCII.GetBytes(dataString);
};
Console.ReadLine();
scan.DeviceEnabled = false;
scan.Release();
scan.Close();
}
The data should be, for example
{220,3 ...
but instead contains
{220,0,3,0 ...
and the attempted code above has the below, which is incorrect
{120,...