Nicke Manarin Nicke Manarin - 13 days ago 8
C# Question

ITF Barcode Algorithm

I have this C#

ITF/Interleaved 2 of 5
algorithm (from a VB Azalea Software algorithm):

public static string Interleaved25(string input)
{
if (input.Length <= 0) return "";

if (input.Length % 2 != 0)
{
input = "0" + input;
}

string result = "";

//Takes pairs of numbers and convert them to chars
for (int i = 0; i <= input.Length - 1; i += 2)
{
int pair = Int32.Parse(input.Substring(i, 2));

if (pair < 90)
pair = pair + 33;
else if (pair == 90)
pair = pair + 182;
else if (pair == 91)
pair = pair + 183;
else if (pair > 91)
pair = pair + 104;

result = result + Convert.ToChar(pair);
}

//Leading and trailing chars.
return (char)171 + result + (char)172;
}


The problem is that somehow
chars
with
value > 89
all have empty boxes as result (using the ITF font).

Answer

While typing this question, I got the answer all by myself.

Here is the new code:

if (pair < 90)
    pair = pair + 33;
else
    {
        pair = pair + 71;
    }

Basically, all chars between 90 and 99 needs a + 71.

New Data