diff --git a/BarcodeStandard/BarcodeCommon.cs b/BarcodeStandard/BarcodeCommon.cs
index 235d4ed..485460e 100644
--- a/BarcodeStandard/BarcodeCommon.cs
+++ b/BarcodeStandard/BarcodeCommon.cs
@@ -14,12 +14,13 @@ protected void Error(string errorMessage)
throw new Exception(errorMessage);
}
- internal static bool CheckNumericOnly(string data)
+ internal static bool IsNumericOnly(string s)
{
- foreach (var c in data)
- {
- if (c < '0' && c > '9') return false;
- }
+ if (s == null || s == "") return false;
+
+ for (int i = 0; i < s.Length; i++)
+ if ((s[i] ^ '0') > 9)
+ return false;
return true;
}
diff --git a/BarcodeStandard/BarcodeLib.cs b/BarcodeStandard/BarcodeLib.cs
index e7de2e9..4670c7f 100644
--- a/BarcodeStandard/BarcodeLib.cs
+++ b/BarcodeStandard/BarcodeLib.cs
@@ -9,6 +9,7 @@
using System.Xml.Serialization;
using BarcodeLib;
using BarcodeLib.Symbologies;
+using BarcodeStandard.Symbologies;
using SkiaSharp;
/*
@@ -27,7 +28,7 @@ namespace BarcodeStandard
{
#region Enums
public enum Type
- { Unspecified, UpcA, UpcE, UpcSupplemental2Digit, UpcSupplemental5Digit, Ean13, Ean8, Interleaved2Of5, Interleaved2Of5Mod10, Standard2Of5, Standard2Of5Mod10, Industrial2Of5, Industrial2Of5Mod10, Code39, Code39Extended, Code39Mod43, Codabar, PostNet, Bookland, Isbn, Jan13, MsiMod10, Msi2Mod10, MsiMod11, MsiMod11Mod10, ModifiedPlessey, Code11, Usd8, Ucc12, Ucc13, Logmars, Code128, Code128A, Code128B, Code128C, Itf14, Code93, Telepen, Fim, Pharmacode }
+ { Unspecified, UpcA, UpcE, UpcSupplemental2Digit, UpcSupplemental5Digit, Ean13, Ean8, Interleaved2Of5, Interleaved2Of5Mod10, Standard2Of5, Standard2Of5Mod10, Industrial2Of5, Industrial2Of5Mod10, Code39, Code39Extended, Code39Mod43, Codabar, PostNet, Bookland, Isbn, Jan13, MsiMod10, Msi2Mod10, MsiMod11, MsiMod11Mod10, ModifiedPlessey, Code11, Usd8, Ucc12, Ucc13, Logmars, Code128, Code128A, Code128B, Code128C, Itf14, Code93, Telepen, Fim, Pharmacode, IATA2of5 }
public enum SaveTypes
{ Jpg, Png, Webp, Unspecified }
public enum AlignmentPositions
@@ -331,6 +332,9 @@ public string GenerateBarcode(string rawData = "")
case Type.Standard2Of5: //Encode_Standard2of5();
_iBarcode = new Standard2of5(RawData, EncodedType);
break;
+ case Type.IATA2of5: //Encode_IATA2of5();
+ _iBarcode = new IATA2of5(RawData);
+ break;
case Type.Logmars:
case Type.Code39: //Encode_Code39();
_iBarcode = new Code39(RawData);
diff --git a/BarcodeStandard/Symbologies/Blank.cs b/BarcodeStandard/Symbologies/Blank.cs
index 7daed42..ae6d40f 100644
--- a/BarcodeStandard/Symbologies/Blank.cs
+++ b/BarcodeStandard/Symbologies/Blank.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// Blank encoding template
/// Written by: Brad Barnhill
///
- class Blank: BarcodeCommon, IBarcode
+ internal class Blank: BarcodeCommon, IBarcode
{
#region IBarcode Members
diff --git a/BarcodeStandard/Symbologies/Codabar.cs b/BarcodeStandard/Symbologies/Codabar.cs
index 3884a4c..6691250 100644
--- a/BarcodeStandard/Symbologies/Codabar.cs
+++ b/BarcodeStandard/Symbologies/Codabar.cs
@@ -6,7 +6,7 @@ namespace BarcodeLib.Symbologies
/// Codabar encoding
/// Written by: Brad Barnhill
///
- class Codabar: BarcodeCommon, IBarcode
+ internal class Codabar : BarcodeCommon, IBarcode
{
private readonly System.Collections.Hashtable Codabar_Code = new System.Collections.Hashtable(); //is initialized by init_Codabar()
@@ -52,14 +52,14 @@ private string Encode_Codabar()
foreach (char c in Codabar_Code.Keys)
{
- if (!CheckNumericOnly(c.ToString()))
+ if (!IsNumericOnly(c.ToString()))
{
temp = temp.Replace(c, '1');
}//if
}//if
//now that all the valid non-numeric chars have been replaced with a number check if all numeric exist
- if (!CheckNumericOnly(temp))
+ if (!IsNumericOnly(temp))
Error("ECODABAR-4: Data contains invalid characters.");
var result = "";
diff --git a/BarcodeStandard/Symbologies/Code11.cs b/BarcodeStandard/Symbologies/Code11.cs
index 5b760d9..6973019 100644
--- a/BarcodeStandard/Symbologies/Code11.cs
+++ b/BarcodeStandard/Symbologies/Code11.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// Code 11 encoding
/// Written by: Brad Barnhill
///
- class Code11 : BarcodeCommon, IBarcode
+ internal class Code11 : BarcodeCommon, IBarcode
{
private readonly string[] C11_Code = { "101011", "1101011", "1001011", "1100101", "1011011", "1101101", "1001101", "1010011", "1101001", "110101", "101101", "1011001" };
@@ -20,7 +20,7 @@ public Code11(string input)
///
private string Encode_Code11()
{
- if (!CheckNumericOnly(RawData.Replace("-", "")))
+ if (!IsNumericOnly(RawData.Replace("-", "")))
Error("EC11-1: Numeric data and '-' Only");
//calculate the checksums
diff --git a/BarcodeStandard/Symbologies/Code128.cs b/BarcodeStandard/Symbologies/Code128.cs
index 3a61ea5..ceb4bea 100644
--- a/BarcodeStandard/Symbologies/Code128.cs
+++ b/BarcodeStandard/Symbologies/Code128.cs
@@ -8,7 +8,7 @@ namespace BarcodeLib.Symbologies
/// Code 128 encoding
/// Written by: Brad Barnhill
///
- class Code128 : BarcodeCommon, IBarcode
+ internal class Code128 : BarcodeCommon, IBarcode
{
public static readonly char FNC1 = Convert.ToChar(200);
public static readonly char FNC2 = Convert.ToChar(201);
diff --git a/BarcodeStandard/Symbologies/Code39.cs b/BarcodeStandard/Symbologies/Code39.cs
index 5163cf3..b96e01c 100644
--- a/BarcodeStandard/Symbologies/Code39.cs
+++ b/BarcodeStandard/Symbologies/Code39.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// Code 39 encoding
/// Written by: Brad Barnhill
///
- class Code39 : BarcodeCommon, IBarcode
+ internal class Code39 : BarcodeCommon, IBarcode
{
private readonly System.Collections.Hashtable C39_Code = new System.Collections.Hashtable(); //is initialized by init_Code39()
private readonly System.Collections.Hashtable ExtC39_Translation = new System.Collections.Hashtable();
diff --git a/BarcodeStandard/Symbologies/Code93.cs b/BarcodeStandard/Symbologies/Code93.cs
index 9f33ece..3402c83 100644
--- a/BarcodeStandard/Symbologies/Code93.cs
+++ b/BarcodeStandard/Symbologies/Code93.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// Code 93 encoding
/// Written by: Brad Barnhill
///
- class Code93 : BarcodeCommon, IBarcode
+ internal class Code93 : BarcodeCommon, IBarcode
{
private readonly System.Data.DataTable C93_Code = new System.Data.DataTable("C93_Code");
diff --git a/BarcodeStandard/Symbologies/EAN13.cs b/BarcodeStandard/Symbologies/EAN13.cs
index c323c8e..e83ac3c 100644
--- a/BarcodeStandard/Symbologies/EAN13.cs
+++ b/BarcodeStandard/Symbologies/EAN13.cs
@@ -8,7 +8,7 @@ namespace BarcodeLib.Symbologies
/// EAN-13 encoding
/// Written by: Brad Barnhill
///
- class EAN13 : BarcodeCommon, IBarcode
+ internal class EAN13 : BarcodeCommon, IBarcode
{
private readonly string[] EAN_CodeA = { "0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };
private readonly string[] EAN_CodeB = { "0100111", "0110011", "0011011", "0100001", "0011101", "0111001", "0000101", "0010001", "0001001", "0010111" };
@@ -41,7 +41,7 @@ private string Encode_EAN13()
if (RawData.Length < 12 || RawData.Length > 13)
Error("EEAN13-1: Data length invalid. (Length must be 12 or 13)");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EEAN13-2: Numeric Data Only");
var patterncode = EAN_Pattern[Int32.Parse(RawData[0].ToString())];
diff --git a/BarcodeStandard/Symbologies/EAN8.cs b/BarcodeStandard/Symbologies/EAN8.cs
index d05022e..31e69f5 100644
--- a/BarcodeStandard/Symbologies/EAN8.cs
+++ b/BarcodeStandard/Symbologies/EAN8.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// EAN-8 encoding
/// Written by: Brad Barnhill
///
- class EAN8 : BarcodeCommon, IBarcode
+ internal class EAN8 : BarcodeCommon, IBarcode
{
private readonly string[] EAN_CodeA = { "0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };
private readonly string[] EAN_CodeC = { "1110010", "1100110", "1101100", "1000010", "1011100", "1001110", "1010000", "1000100", "1001000", "1110100" };
@@ -17,7 +17,8 @@ public EAN8(string input)
RawData = input;
//check numeric only
- if (!CheckNumericOnly(RawData)) Error("EEAN8-2: Numeric only.");
+ if (!IsNumericOnly(RawData))
+ Error("EEAN8-2: Numeric only.");
CheckDigit();
}
diff --git a/BarcodeStandard/Symbologies/FIM.cs b/BarcodeStandard/Symbologies/FIM.cs
index 772f61d..9ad23aa 100644
--- a/BarcodeStandard/Symbologies/FIM.cs
+++ b/BarcodeStandard/Symbologies/FIM.cs
@@ -6,7 +6,7 @@ namespace BarcodeLib.Symbologies
/// FIM encoding
/// Written by: Brad Barnhill
///
- class FIM: BarcodeCommon, IBarcode
+ internal class FIM : BarcodeCommon, IBarcode
{
private readonly string[] FIM_Codes = { "110010011", "101101101", "110101011", "111010111", "101000101" };
public enum FIMTypes {FIM_A = 0, FIM_B, FIM_C, FIM_D, FIM_E};
diff --git a/BarcodeStandard/Symbologies/IATA2of5.cs b/BarcodeStandard/Symbologies/IATA2of5.cs
new file mode 100644
index 0000000..6f6f3a0
--- /dev/null
+++ b/BarcodeStandard/Symbologies/IATA2of5.cs
@@ -0,0 +1,74 @@
+using BarcodeLib;
+using BarcodeLib.Symbologies;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BarcodeStandard.Symbologies
+{
+ internal class IATA2of5 : BarcodeCommon, IBarcode
+ {
+ private readonly string[] IATA2of5_Code = { "10101110111010", "11101010101110", "10111010101110", "11101110101010", "10101110101110", "11101011101010", "10111011101010", "10101011101110", "11101010111010", "10111010111010" };
+
+ public IATA2of5(string input)
+ {
+ RawData = input;
+ }//Standard2of5
+
+ ///
+ /// Encode the raw data using the IATA 2 of 5 algorithm.
+ ///
+ private string Encode_IATA2of5()
+ {
+ //check length of input
+ if (RawData.Length > 17 || RawData.Length < 16)
+ Error("EIATA25-1: Data length invalid. (Length must be 16 or 17)");
+
+ if (!IsNumericOnly(RawData))
+ Error("EIATA25-2: Numeric Data Only");
+
+ //strip check digit if provided so it can be recalculated
+ 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 < RawData.Length; i++)
+ {
+ result += IATA2of5_Code[(int)char.GetNumericValue(RawData, i)];
+ }
+
+ //add check digit
+ result += IATA2of5_Code[checkdigit];
+
+ //add ending bars
+ result += "01101";
+ return result;
+ }//Encode_Standard2of5
+
+ private int CalculateMod10CheckDigit()
+ {
+ var sum = 0;
+ var even = true;
+
+ for (var i = RawData.Length - 1; i >= 0; --i)
+ {
+ //convert numeric in char format to integer and
+ //multiply by 3 or 1 based on if an even index from the end
+ sum += (RawData[i] - '0') * (even ? 3 : 1);
+ even = !even;
+ }
+
+ return (10 - sum % 10) % 10;
+ }
+
+ #region IBarcode Members
+
+ public string Encoded_Value => Encode_IATA2of5();
+
+ #endregion
+ }
+}
diff --git a/BarcodeStandard/Symbologies/ISBN.cs b/BarcodeStandard/Symbologies/ISBN.cs
index 5910680..9e87d7a 100644
--- a/BarcodeStandard/Symbologies/ISBN.cs
+++ b/BarcodeStandard/Symbologies/ISBN.cs
@@ -6,7 +6,7 @@ namespace BarcodeLib.Symbologies
/// ISBN encoding
/// Written by: Brad Barnhill
///
- class ISBN : BarcodeCommon, IBarcode
+ internal class ISBN : BarcodeCommon, IBarcode
{
public ISBN(string input)
{
@@ -17,7 +17,7 @@ public ISBN(string input)
///
private string Encode_ISBN_Bookland()
{
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EBOOKLANDISBN-1: Numeric Data Only");
var type = "UNKNOWN";
diff --git a/BarcodeStandard/Symbologies/ITF14.cs b/BarcodeStandard/Symbologies/ITF14.cs
index aae2edf..e24c602 100644
--- a/BarcodeStandard/Symbologies/ITF14.cs
+++ b/BarcodeStandard/Symbologies/ITF14.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// ITF-14 encoding
/// Written by: Brad Barnhill
///
- class ITF14 : BarcodeCommon, IBarcode
+ internal class ITF14 : BarcodeCommon, IBarcode
{
private readonly string[] ITF14_Code = { "NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW", "WNWNN", "NWWNN", "NNNWW", "WNNWN", "NWNWN" };
@@ -26,7 +26,7 @@ private string Encode_ITF14()
if (RawData.Length > 14 || RawData.Length < 13)
Error("EITF14-1: Data length invalid. (Length must be 13 or 14)");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EITF14-2: Numeric data only.");
var result = "1010";
diff --git a/BarcodeStandard/Symbologies/Interleaved2of5.cs b/BarcodeStandard/Symbologies/Interleaved2of5.cs
index a187c3a..055e376 100644
--- a/BarcodeStandard/Symbologies/Interleaved2of5.cs
+++ b/BarcodeStandard/Symbologies/Interleaved2of5.cs
@@ -8,7 +8,7 @@ namespace BarcodeLib.Symbologies
/// Interleaved 2 of 5 encoding
/// Written by: Brad Barnhill
///
- class Interleaved2of5 : BarcodeCommon, IBarcode
+ internal class Interleaved2of5 : BarcodeCommon, IBarcode
{
private readonly string[] _i25Code = { "NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW", "WNWNN", "NWWNN", "NNNWW", "WNNWN", "NWNWN" };
private readonly Type _encodedType;
@@ -27,7 +27,7 @@ private string Encode_Interleaved2of5()
if (RawData.Length % 2 != (_encodedType == Type.Interleaved2Of5Mod10 ? 1 : 0))
Error("EI25-1: Data length invalid.");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EI25-2: Numeric Data Only");
var result = "1010";
diff --git a/BarcodeStandard/Symbologies/JAN13.cs b/BarcodeStandard/Symbologies/JAN13.cs
index 05557fc..843ad6a 100644
--- a/BarcodeStandard/Symbologies/JAN13.cs
+++ b/BarcodeStandard/Symbologies/JAN13.cs
@@ -6,7 +6,7 @@ namespace BarcodeLib.Symbologies
/// JAN-13 encoding
/// Written by: Brad Barnhill
///
- class JAN13 : BarcodeCommon, IBarcode
+ internal class JAN13 : BarcodeCommon, IBarcode
{
public JAN13(string input)
{
@@ -18,7 +18,7 @@ public JAN13(string input)
private string Encode_JAN13()
{
if (!RawData.StartsWith("49")) Error("EJAN13-1: Invalid Country Code for JAN13 (49 required)");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EJAN13-2: Numeric Data Only");
EAN13 ean13 = new EAN13(RawData);
diff --git a/BarcodeStandard/Symbologies/MSI.cs b/BarcodeStandard/Symbologies/MSI.cs
index 237e2fe..0fd8b95 100644
--- a/BarcodeStandard/Symbologies/MSI.cs
+++ b/BarcodeStandard/Symbologies/MSI.cs
@@ -4,7 +4,7 @@
namespace BarcodeLib.Symbologies
{
- class MSI : BarcodeCommon, IBarcode
+ internal class MSI : BarcodeCommon, IBarcode
{
///
/// MSI encoding
@@ -25,7 +25,7 @@ public MSI(string input, Type encodedType)
private string Encode_MSI()
{
//check for non-numeric chars
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EMSI-1: Numeric Data Only");
//get checksum
diff --git a/BarcodeStandard/Symbologies/Pharmacode.cs b/BarcodeStandard/Symbologies/Pharmacode.cs
index 90dd467..edc43af 100644
--- a/BarcodeStandard/Symbologies/Pharmacode.cs
+++ b/BarcodeStandard/Symbologies/Pharmacode.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// Pharmacode encoding
/// Written by: Brad Barnhill
///
- class Pharmacode: BarcodeCommon, IBarcode
+ internal class Pharmacode : BarcodeCommon, IBarcode
{
string _thinBar = "1";
string _gap = "00";
@@ -21,7 +21,7 @@ public Pharmacode(string input)
{
RawData = input;
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
{
Error("EPHARM-1: Data contains invalid characters (non-numeric).");
}//if
diff --git a/BarcodeStandard/Symbologies/Postnet.cs b/BarcodeStandard/Symbologies/Postnet.cs
index 82b374e..aff3c4b 100644
--- a/BarcodeStandard/Symbologies/Postnet.cs
+++ b/BarcodeStandard/Symbologies/Postnet.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// Postnet encoding
/// Written by: Brad Barnhill
///
- class Postnet : BarcodeCommon, IBarcode
+ internal class Postnet : BarcodeCommon, IBarcode
{
private readonly string[] POSTNET_Code = { "11000", "00011", "00101", "00110", "01001", "01010", "01100", "10001", "10010", "10100" };
diff --git a/BarcodeStandard/Symbologies/Standard2of5.cs b/BarcodeStandard/Symbologies/Standard2of5.cs
index 1250fd2..77a3503 100644
--- a/BarcodeStandard/Symbologies/Standard2of5.cs
+++ b/BarcodeStandard/Symbologies/Standard2of5.cs
@@ -8,7 +8,7 @@ namespace BarcodeLib.Symbologies
/// Standard 2 of 5 encoding
/// Written by: Brad Barnhill
///
- class Standard2of5 : BarcodeCommon, IBarcode
+ internal class Standard2of5 : BarcodeCommon, IBarcode
{
private readonly string[] S25_Code = { "10101110111010", "11101010101110", "10111010101110", "11101110101010", "10101110101110", "11101011101010", "10111011101010", "10101011101110", "11101010111010", "10111010111010" };
private readonly Type _encodedType = Type.Unspecified;
@@ -24,7 +24,7 @@ public Standard2of5(string input, Type encodedType)
///
private string Encode_Standard2of5()
{
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("ES25-1: Numeric Data Only");
var result = "11011010";
diff --git a/BarcodeStandard/Symbologies/Telepen.cs b/BarcodeStandard/Symbologies/Telepen.cs
index 0ad42ef..5c47d8c 100644
--- a/BarcodeStandard/Symbologies/Telepen.cs
+++ b/BarcodeStandard/Symbologies/Telepen.cs
@@ -8,7 +8,7 @@ namespace BarcodeLib.Symbologies
/// Telepen encoding
/// Written by: Brad Barnhill
///
- class Telepen: BarcodeCommon, IBarcode
+ internal class Telepen : BarcodeCommon, IBarcode
{
private static readonly Hashtable Telepen_Code = new Hashtable();
private enum StartStopCode : int { START1, STOP1, START2, STOP2, START3, STOP3 };
diff --git a/BarcodeStandard/Symbologies/UPCA.cs b/BarcodeStandard/Symbologies/UPCA.cs
index a193d96..48d045e 100644
--- a/BarcodeStandard/Symbologies/UPCA.cs
+++ b/BarcodeStandard/Symbologies/UPCA.cs
@@ -8,7 +8,7 @@ namespace BarcodeLib.Symbologies
/// UPC-A encoding
/// Written by: Brad Barnhill
///
- class UPCA : BarcodeCommon, IBarcode
+ internal class UPCA : BarcodeCommon, IBarcode
{
private readonly string[] UPC_Code_A = { "0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };
private readonly string[] UPC_Code_B = { "1110010", "1100110", "1101100", "1000010", "1011100", "1001110", "1010000", "1000100", "1001000", "1110100" };
@@ -28,7 +28,7 @@ private string Encode_UPCA()
if (RawData.Length != 11 && RawData.Length != 12)
Error("EUPCA-1: Data length invalid. (Length must be 11 or 12)");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EUPCA-2: Numeric Data Only");
CheckDigit();
diff --git a/BarcodeStandard/Symbologies/UPCE.cs b/BarcodeStandard/Symbologies/UPCE.cs
index c2a70f2..cf5403c 100644
--- a/BarcodeStandard/Symbologies/UPCE.cs
+++ b/BarcodeStandard/Symbologies/UPCE.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// UPC-E encoding
/// Written by: Brad Barnhill
///
- class UPCE : BarcodeCommon, IBarcode
+ internal class UPCE : BarcodeCommon, IBarcode
{
private readonly string[] EAN_Code_A = { "0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };
private readonly string[] EAN_Code_B = { "0100111", "0110011", "0011011", "0100001", "0011101", "0111001", "0000101", "0010001", "0001001", "0010111" };
@@ -31,7 +31,7 @@ private string Encode_UPCE()
if (RawData.Length != 6 && RawData.Length != 8 && RawData.Length != 12)
Error("EUPCE-1: Invalid data length. (8 or 12 numbers only)");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EUPCE-2: Numeric only.");
//check for a valid number system
diff --git a/BarcodeStandard/Symbologies/UPCSupplement2.cs b/BarcodeStandard/Symbologies/UPCSupplement2.cs
index b9baa60..e8c07ec 100644
--- a/BarcodeStandard/Symbologies/UPCSupplement2.cs
+++ b/BarcodeStandard/Symbologies/UPCSupplement2.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// UPC Supplement-2 encoding
/// Written by: Brad Barnhill
///
- class UPCSupplement2 : BarcodeCommon, IBarcode
+ internal class UPCSupplement2 : BarcodeCommon, IBarcode
{
private readonly string [] EAN_CodeA = { "0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };
private readonly string [] EAN_CodeB = { "0100111", "0110011", "0011011", "0100001", "0011101", "0111001", "0000101", "0010001", "0001001", "0010111" };
@@ -25,7 +25,7 @@ private string Encode_UPCSupplemental_2()
{
if (RawData.Length != 2) Error("EUPC-SUP2-1: Invalid data length. (Length = 2 required)");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EUPC-SUP2-2: Numeric Data Only");
string pattern = "";
diff --git a/BarcodeStandard/Symbologies/UPCSupplement5.cs b/BarcodeStandard/Symbologies/UPCSupplement5.cs
index df8c382..9515a49 100644
--- a/BarcodeStandard/Symbologies/UPCSupplement5.cs
+++ b/BarcodeStandard/Symbologies/UPCSupplement5.cs
@@ -7,7 +7,7 @@ namespace BarcodeLib.Symbologies
/// UPC Supplement-5 encoding
/// Written by: Brad Barnhill
///
- class UPCSupplement5 : BarcodeCommon, IBarcode
+ internal class UPCSupplement5 : BarcodeCommon, IBarcode
{
private readonly string[] EAN_CodeA = { "0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };
private readonly string[] EAN_CodeB = { "0100111", "0110011", "0011011", "0100001", "0011101", "0111001", "0000101", "0010001", "0001001", "0010111" };
@@ -25,7 +25,7 @@ private string Encode_UPCSupplemental_5()
{
if (RawData.Length != 5) Error("EUPC-SUP5-1: Invalid data length. (Length = 5 required)");
- if (!CheckNumericOnly(RawData))
+ if (!IsNumericOnly(RawData))
Error("EUPCA-2: Numeric Data Only");
//calculate the checksum digit
diff --git a/BarcodeStandardExample/TestApp.Designer.cs b/BarcodeStandardExample/TestApp.Designer.cs
index ce07620..b6b098e 100644
--- a/BarcodeStandardExample/TestApp.Designer.cs
+++ b/BarcodeStandardExample/TestApp.Designer.cs
@@ -96,10 +96,10 @@ private void InitializeComponent()
this.tsslEncodedType,
this.tslblLibraryVersion,
this.tslblCredits});
- this.statusStrip1.Location = new System.Drawing.Point(0, 550);
+ this.statusStrip1.Location = new System.Drawing.Point(0, 556);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Padding = new System.Windows.Forms.Padding(2, 0, 14, 0);
- this.statusStrip1.Size = new System.Drawing.Size(1015, 30);
+ this.statusStrip1.Size = new System.Drawing.Size(1015, 24);
this.statusStrip1.SizingGrip = false;
this.statusStrip1.TabIndex = 30;
this.statusStrip1.Text = "statusStrip1";
@@ -108,20 +108,20 @@ private void InitializeComponent()
//
this.tsslEncodedType.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
this.tsslEncodedType.Name = "tsslEncodedType";
- this.tsslEncodedType.Size = new System.Drawing.Size(4, 24);
+ this.tsslEncodedType.Size = new System.Drawing.Size(4, 19);
//
// tslblLibraryVersion
//
this.tslblLibraryVersion.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right;
this.tslblLibraryVersion.Name = "tslblLibraryVersion";
- this.tslblLibraryVersion.Size = new System.Drawing.Size(825, 24);
+ this.tslblLibraryVersion.Size = new System.Drawing.Size(860, 19);
this.tslblLibraryVersion.Spring = true;
this.tslblLibraryVersion.Text = "LibVersion";
//
// tslblCredits
//
this.tslblCredits.Name = "tslblCredits";
- this.tslblCredits.Size = new System.Drawing.Size(170, 24);
+ this.tslblCredits.Size = new System.Drawing.Size(135, 19);
this.tslblCredits.Text = "Written by: Brad Barnhill";
this.tslblCredits.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
@@ -131,7 +131,7 @@ private void InitializeComponent()
this.barcode.Dock = System.Windows.Forms.DockStyle.Fill;
this.barcode.Location = new System.Drawing.Point(0, 0);
this.barcode.Name = "barcode";
- this.barcode.Size = new System.Drawing.Size(711, 550);
+ this.barcode.Size = new System.Drawing.Size(711, 556);
this.barcode.TabIndex = 36;
this.barcode.TabStop = false;
this.barcode.Text = "Barcode Image";
@@ -139,7 +139,7 @@ private void InitializeComponent()
// btnMassGeneration
//
this.btnMassGeneration.Location = new System.Drawing.Point(4, 16);
- this.btnMassGeneration.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.btnMassGeneration.Margin = new System.Windows.Forms.Padding(2);
this.btnMassGeneration.Name = "btnMassGeneration";
this.btnMassGeneration.Size = new System.Drawing.Size(121, 33);
this.btnMassGeneration.TabIndex = 0;
@@ -179,7 +179,7 @@ private void InitializeComponent()
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.barcode);
- this.splitContainer1.Size = new System.Drawing.Size(1015, 550);
+ this.splitContainer1.Size = new System.Drawing.Size(1015, 556);
this.splitContainer1.SplitterDistance = 300;
this.splitContainer1.TabIndex = 37;
this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved);
@@ -191,9 +191,9 @@ private void InitializeComponent()
this.groupBox2.Controls.Add(this.lblAverageGenerationTime);
this.groupBox2.Controls.Add(this.label14);
this.groupBox2.Location = new System.Drawing.Point(8, 472);
- this.groupBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.groupBox2.Margin = new System.Windows.Forms.Padding(2);
this.groupBox2.Name = "groupBox2";
- this.groupBox2.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.groupBox2.Padding = new System.Windows.Forms.Padding(2);
this.groupBox2.Size = new System.Drawing.Size(290, 80);
this.groupBox2.TabIndex = 85;
this.groupBox2.TabStop = false;
@@ -211,7 +211,7 @@ private void InitializeComponent()
this.lblAverageGenerationTime.AutoSize = true;
this.lblAverageGenerationTime.Location = new System.Drawing.Point(136, 63);
this.lblAverageGenerationTime.Name = "lblAverageGenerationTime";
- this.lblAverageGenerationTime.Size = new System.Drawing.Size(0, 15);
+ this.lblAverageGenerationTime.Size = new System.Drawing.Size(0, 13);
this.lblAverageGenerationTime.TabIndex = 81;
//
// label14
@@ -219,7 +219,7 @@ private void InitializeComponent()
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(3, 63);
this.label14.Name = "label14";
- this.label14.Size = new System.Drawing.Size(152, 15);
+ this.label14.Size = new System.Drawing.Size(134, 13);
this.label14.TabIndex = 80;
this.label14.Text = "Average Generation Time: ";
//
@@ -233,9 +233,9 @@ private void InitializeComponent()
this.groupBox1.Controls.Add(this.btnSave);
this.groupBox1.Controls.Add(this.btnEncode);
this.groupBox1.Location = new System.Drawing.Point(8, 378);
- this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.groupBox1.Margin = new System.Windows.Forms.Padding(2);
this.groupBox1.Name = "groupBox1";
- this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.groupBox1.Padding = new System.Windows.Forms.Padding(2);
this.groupBox1.Size = new System.Drawing.Size(282, 90);
this.groupBox1.TabIndex = 84;
this.groupBox1.TabStop = false;
@@ -244,9 +244,9 @@ private void InitializeComponent()
//
this.chkIncludeImageInSavedData.AutoSize = true;
this.chkIncludeImageInSavedData.Location = new System.Drawing.Point(186, 70);
- this.chkIncludeImageInSavedData.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+ this.chkIncludeImageInSavedData.Margin = new System.Windows.Forms.Padding(2);
this.chkIncludeImageInSavedData.Name = "chkIncludeImageInSavedData";
- this.chkIncludeImageInSavedData.Size = new System.Drawing.Size(107, 19);
+ this.chkIncludeImageInSavedData.Size = new System.Drawing.Size(93, 17);
this.chkIncludeImageInSavedData.TabIndex = 0;
this.chkIncludeImageInSavedData.Text = "Include Image";
this.chkIncludeImageInSavedData.UseVisualStyleBackColor = true;
@@ -347,7 +347,7 @@ private void InitializeComponent()
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(58, 50);
this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(72, 15);
+ this.label13.Size = new System.Drawing.Size(65, 13);
this.label13.TabIndex = 53;
this.label13.Text = "AspectRatio";
//
@@ -356,7 +356,7 @@ private void InitializeComponent()
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(8, 50);
this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(57, 15);
+ this.label12.Size = new System.Drawing.Size(51, 13);
this.label12.TabIndex = 52;
this.label12.Text = "BarWidth";
//
@@ -373,7 +373,7 @@ private void InitializeComponent()
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(16, 8);
this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(38, 15);
+ this.label7.Size = new System.Drawing.Size(35, 13);
this.label7.TabIndex = 41;
this.label7.Text = "Width";
//
@@ -382,7 +382,7 @@ private void InitializeComponent()
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(62, 8);
this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(43, 15);
+ this.label6.Size = new System.Drawing.Size(38, 13);
this.label6.TabIndex = 42;
this.label6.Text = "Height";
//
@@ -399,7 +399,7 @@ private void InitializeComponent()
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(53, 28);
this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(13, 15);
+ this.label9.Size = new System.Drawing.Size(12, 13);
this.label9.TabIndex = 51;
this.label9.Text = "x";
//
@@ -426,7 +426,7 @@ private void InitializeComponent()
this.chkGenerateLabel.AutoSize = true;
this.chkGenerateLabel.Location = new System.Drawing.Point(6, 15);
this.chkGenerateLabel.Name = "chkGenerateLabel";
- this.chkGenerateLabel.Size = new System.Drawing.Size(110, 19);
+ this.chkGenerateLabel.Size = new System.Drawing.Size(95, 17);
this.chkGenerateLabel.TabIndex = 40;
this.chkGenerateLabel.Text = "Generate label";
this.chkGenerateLabel.UseVisualStyleBackColor = true;
@@ -436,7 +436,7 @@ private void InitializeComponent()
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(3, 39);
this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(115, 15);
+ this.label11.Size = new System.Drawing.Size(102, 13);
this.label11.TabIndex = 55;
this.label11.Text = "Alternate Label Text";
//
@@ -445,7 +445,7 @@ private void InitializeComponent()
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(6, 93);
this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(62, 15);
+ this.label8.Size = new System.Drawing.Size(53, 13);
this.label8.TabIndex = 74;
this.label8.Text = "Alignment";
//
@@ -454,7 +454,7 @@ private void InitializeComponent()
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(7, 141);
this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(71, 15);
+ this.label4.Size = new System.Drawing.Size(61, 13);
this.label4.TabIndex = 68;
this.label4.Text = "Foreground";
//
@@ -474,7 +474,7 @@ private void InitializeComponent()
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(70, 141);
this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(73, 15);
+ this.label5.Size = new System.Drawing.Size(65, 13);
this.label5.TabIndex = 69;
this.label5.Text = "Background";
//
@@ -516,7 +516,7 @@ private void InitializeComponent()
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(5, 209);
this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(90, 15);
+ this.label2.Size = new System.Drawing.Size(80, 13);
this.label2.TabIndex = 64;
this.label2.Text = "Encoded Value";
//
@@ -525,7 +525,7 @@ private void InitializeComponent()
this.lblEncodingTime.AutoSize = true;
this.lblEncodingTime.Location = new System.Drawing.Point(89, 207);
this.lblEncodingTime.Name = "lblEncodingTime";
- this.lblEncodingTime.Size = new System.Drawing.Size(0, 15);
+ this.lblEncodingTime.Size = new System.Drawing.Size(0, 13);
this.lblEncodingTime.TabIndex = 70;
//
// label3
@@ -533,7 +533,7 @@ private void InitializeComponent()
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 48);
this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(59, 15);
+ this.label3.Size = new System.Drawing.Size(52, 13);
this.label3.TabIndex = 65;
this.label3.Text = "Encoding";
//
@@ -555,6 +555,7 @@ private void InitializeComponent()
"Interleaved 2 of 5 Mod 10",
"Standard 2 of 5",
"Standard 2 of 5 Mod 10",
+ "IATA2of5",
"Codabar",
"PostNet",
"Bookland/ISBN",
@@ -593,7 +594,7 @@ private void InitializeComponent()
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(5, 8);
this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(96, 15);
+ this.label1.Size = new System.Drawing.Size(86, 13);
this.label1.TabIndex = 63;
this.label1.Text = "Value to Encode";
//
diff --git a/BarcodeStandardExample/TestApp.cs b/BarcodeStandardExample/TestApp.cs
index 3bbb4e8..5059806 100644
--- a/BarcodeStandardExample/TestApp.cs
+++ b/BarcodeStandardExample/TestApp.cs
@@ -82,10 +82,10 @@ private void btnEncode_Click(object sender, EventArgs e)
//===== Encoding performed here =====
barcode.BackgroundImage = Image.FromStream(_b.Encode(type, txtData.Text.Trim(), _b.ForeColor, _b.BackColor, w, h).Encode().AsStream());
//===================================
-
+
//show the encoding time
lblEncodingTime.Text = @"(" + Math.Round(_b.EncodingTime, 0, MidpointRounding.AwayFromZero) + @"ms)";
-
+
txtEncoded.Text = _b.EncodedValue;
tsslEncodedType.Text = @"Encoding Type: " + _b.EncodedType;
@@ -160,6 +160,7 @@ private Type GetTypeSelected()
case "Telepen": type = Type.Telepen; break;
case "FIM": type = Type.Fim; break;
case "Pharmacode": type = Type.Pharmacode; break;
+ case "IATA2of5": type = Type.IATA2of5; break;
default: MessageBox.Show(@"Please specify the encoding type."); break;
}//switch
@@ -386,6 +387,9 @@ private void LoadFromSaveData(SaveData saveData)
case "Pharmacode":
cbEncodeType.SelectedIndex = cbEncodeType.FindString("Pharmacode");
break;
+ case "IATA2of5":
+ cbEncodeType.SelectedIndex = cbEncodeType.FindString("IATA2of5");
+ break;
default: throw new Exception("ELOADXML-1: Unsupported encoding type in XML.");
}//switch
diff --git a/BarcodeStandardTests/Symbologies/IATA2of5Tests.cs b/BarcodeStandardTests/Symbologies/IATA2of5Tests.cs
new file mode 100644
index 0000000..80d36a3
--- /dev/null
+++ b/BarcodeStandardTests/Symbologies/IATA2of5Tests.cs
@@ -0,0 +1,24 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using BarcodeStandard;
+
+namespace BarcodeStandardTests.Symbologies
+{
+ [TestClass]
+ public class IATA2of5Tests
+ {
+ private readonly Barcode _barcode = new()
+ {
+ EncodedType = Type.IATA2of5,
+ };
+
+ [DataTestMethod]
+ [DataRow("0380003562164928", "101010101110111010111011101010101110101011101010101110111010101011101110101010111011101011101110101010111010111010101011101110101010111010101110111010101011101011101110101010101110101110101110101110101011101010111011101010111010101010111011101010101110111001101")]
+ [DataRow("12345678901234567", "101011101010101110101110101011101110111010101010101110101110111010111010101011101110101010101011101110111010101110101011101011101010101110111010111010101011101011101010111011101110101010101011101011101110101110101010111011101010101011101110101010111011101001101")]
+ [DataRow("19279472947891274", "101011101010101110101110101110101011101010111010101011101110101110101110101010111010111010101011101110101110101011101011101011101010101110101110101010111011101110101011101010111010111010111010101011101011101010111010101011101110111010101110101110101011101001101")]
+ public void EncodeBarcode(string data, string expected)
+ {
+ _barcode.Encode(data);
+ Assert.AreEqual(expected, _barcode.EncodedValue, $"{_barcode.EncodedType}");
+ }
+ }
+}
diff --git a/README.md b/README.md
index 267b444..f193679 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@ This library was designed to give an easy class for developers to use when they
| ISBN | Codabar | Interleaved 2 of 5 |
| ITF-14 | Telepen | UPC Supplemental 2 |
| JAN-13 | EAN-13 | UPC Supplemental 5 |
+| IATA2of5 | | |
## Usage
@@ -42,4 +43,4 @@ If you find this or any of my software useful and decide its worth supporting.
## Copyright and license
-Copyright 2007-2023 Brad Barnhill. Code released under the [Apache License, Version 2.0](https://github.com/bbarnhill/barcodelib/blob/master/LICENSE).
+Copyright 2007-2024 Brad Barnhill. Code released under the [Apache License, Version 2.0](https://github.com/bbarnhill/barcodelib/blob/master/LICENSE).