Skip to content

Commit

Permalink
add check digit to RawData value so that it shows in the label
Browse files Browse the repository at this point in the history
  • Loading branch information
barnhill committed Apr 27, 2024
1 parent 5fab830 commit f5a088e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions BarcodeStandard/Symbologies/IATA2of5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ private string Encode_IATA2of5()
Error("EIATA25-2: Numeric Data Only");

//strip check digit if provided so it can be recalculated
var raw = RawData.Length == 17 ? RawData.Substring(0, 16) : RawData;
RawData = RawData.Length == 17 ? RawData.Substring(0, 16) : RawData;

//calculate check digit
var checkdigit = CalculateMod10CheckDigit();
RawData += checkdigit.ToString();

var result = "1010";

for (int i = 0; i < raw.Length; i++)
for (int i = 0; i < RawData.Length; i++)
{
result += IATA2of5_Code[(int)char.GetNumericValue(raw, i)];
result += IATA2of5_Code[(int)char.GetNumericValue(RawData, i)];
}

//calculate check digit
result += IATA2of5_Code[CalculateMod10CheckDigit()];
//add check digit
result += IATA2of5_Code[checkdigit];

//add ending bars
result += "01101";
Expand Down

0 comments on commit f5a088e

Please sign in to comment.