Nicke Manarin - 8 months ago 73

C# Question

I have this C#

`ITF/Interleaved 2 of 5`

`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`

`value > 89`

Answer Source

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.