Why does my Code-128 Barcode Encoder not work?

499 Views Asked by At

So, I have a block of text in which there is a barcode. For this I use the Code128 font to display text as a barcode. But it doesn't work that easy with Code 128. So I took the following Encode in the hope that my text would be changed into a scannable barcode. however for some reason i still can't read it.

 public string BarcodeEncode(string value)
    {
        int[] overChars = { 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, 8364 };
        char[] valueChars = value.ToCharArray();
        int[] checksumVals = new int[value.Length];

        for (int n = 0; n < valueChars.Length; n++)
        {
            checksumVals[n] = (((byte)valueChars[n]) - 32) * (n + 1);
        }

        int checksum = checksumVals.Sum() % 103;
        char check = (char)(checksum + 33);
        if (checksum > 93)
            check = (char)overChars[checksum - 94];

        string start = ((char)353).ToString();
        string stop = ((char)339).ToString();

        return start + value + check.ToString() + stop;
    }

Bevor this decoding my BarCode lookslike that:

Before

But I cant scan it with an barcode scanner.

So I did the following method, in the hope that with this change I will be able to scan the barcode with a Bacode scanner.

But after that my Barcode looks like that:

Barcode2

And it doesnt work either

The Input of my Barcode is just a text "Hellooo" nothing special yet

0

There are 0 best solutions below