Ejemplo n.º 1
0
    private int[] StringToCode128(string AsciiData)
    {
        byte[] asciiBytes = Encoding.ASCII.GetBytes(AsciiData);


        Code128Code.CodeSetAllowed csa1 = asciiBytes.Length > 0 ? Code128Code.CodesetAllowedForChar(asciiBytes[0]) : Code128Code.CodeSetAllowed.CodeAorB;
        Code128Code.CodeSetAllowed csa2 = asciiBytes.Length > 1 ? Code128Code.CodesetAllowedForChar(asciiBytes[1]) : Code128Code.CodeSetAllowed.CodeAorB;
        CodeSet currcs = GetBestStartSet(csa1, csa2);


        System.Collections.ArrayList codes = new System.Collections.ArrayList(asciiBytes.Length + 3); // assume no codeset changes, account for start, checksum, and stop
        codes.Add(Code128Code.StartCodeForCodeSet(currcs));

        for (int i = 0; i < asciiBytes.Length; i++)
        {
            int thischar = asciiBytes[i];
            int nextchar = asciiBytes.Length > (i + 1) ? asciiBytes[i + 1] : -1;

            codes.AddRange(Code128Code.CodesForChar(thischar, nextchar, ref currcs));
        }


        int checksum = (int)(codes[0]);

        for (int i = 1; i < codes.Count; i++)
        {
            checksum += i * (int)(codes[i]);
        }
        codes.Add(checksum % 103);

        codes.Add(Code128Code.StopCode());

        int[] result = codes.ToArray(typeof(int)) as int[];
        return(result);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Transform the string into integers representing the Code128 codes
        /// necessary to represent it
        /// </summary>
        /// <param name="asciiData">String to be encoded</param>
        /// <returns>Code128 representation</returns>
        private int[] StringToCode128(string asciiData)
        {
            // turn the string into ascii byte data
            var asciiBytes = Encoding.ASCII.GetBytes(asciiData);

            // decide which codeset to start with
            var csa1 = asciiBytes.Length > 0
                           ? Code128Code.CodesetAllowedForChar(asciiBytes[0])
                           : Code128Code.CodeSetAllowed.CodeAorB;
            var csa2 = asciiBytes.Length > 1
                           ? Code128Code.CodesetAllowedForChar(asciiBytes[1])
                           : Code128Code.CodeSetAllowed.CodeAorB;
            var currentCodeSet = this.GetBestStartSet(csa1, csa2);

            // set up the beginning of the barcode
            // assume no codeset changes, account for start, checksum, and stop
            var codes = new ArrayList(asciiBytes.Length + 3)
            {
                Code128Code.StartCodeForCodeSet(currentCodeSet)
            };

            // add the codes for each character in the string
            for (var i = 0; i < asciiBytes.Length; i++)
            {
                int thischar = asciiBytes[i];
                var nextchar = asciiBytes.Length > i + 1 ? asciiBytes[i + 1] : -1;

                codes.AddRange(Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet));
            }

            // calculate the check digit
            var checksum = (int)codes[0];

            for (var i = 1; i < codes.Count; i++)
            {
                checksum += i * (int)codes[i];
            }

            codes.Add(checksum % 103);

            codes.Add(Code128Code.StopCode());

            var result = codes.ToArray(typeof(int)) as int[];

            return(result);
        }
Ejemplo n.º 3
0
    /// <summary>
    /// Transform the string into integers representing the Code128 codes
    /// necessary to represent it
    /// </summary>
    /// <param name="AsciiData">String to be encoded</param>
    /// <returns>Code128 representation</returns>
    private int[] StringToCode128(string AsciiData)
    {
        // turn the string into ascii byte data
        byte[] asciiBytes = Encoding.ASCII.GetBytes(AsciiData);

        // decide which codeset to start with
        Code128Code.CodeSetAllowed csa1 = asciiBytes.Length > 0 ? Code128Code.CodesetAllowedForChar(asciiBytes[0]) : Code128Code.CodeSetAllowed.CodeAorB;
        Code128Code.CodeSetAllowed csa2 = asciiBytes.Length > 0 ? Code128Code.CodesetAllowedForChar(asciiBytes[1]) : Code128Code.CodeSetAllowed.CodeAorB;
        CodeSet currcs = GetBestStartSet(csa1, csa2);

        // set up the beginning of the barcode
        System.Collections.ArrayList codes = new System.Collections.ArrayList(asciiBytes.Length + 3); // assume no codeset changes, account for start, checksum, and stop
        codes.Add(Code128Code.StartCodeForCodeSet(currcs));

        // add the codes for each character in the string
        for (int i = 0; i < asciiBytes.Length; i++)
        {
            int thischar = asciiBytes[i];
            int nextchar = asciiBytes.Length > (i + 1) ? asciiBytes[i + 1] : -1;

            codes.AddRange(Code128Code.CodesForChar(thischar, nextchar, ref currcs));
        }

        // calculate the check digit
        int checksum = (int)(codes[0]);

        for (int i = 1; i < codes.Count; i++)
        {
            checksum += i * (int)(codes[i]);
        }
        codes.Add(checksum % 103);

        codes.Add(Code128Code.StopCode());

        int[] result = codes.ToArray(typeof(int)) as int[];
        return(result);
    }
Ejemplo n.º 4
0
        public void CharTranslationTests()
        {
            CodeSet currcs, origcs;
            int     thischar, nextchar;

            int[] resultcodes;

            // in CodeA, thischar Either, nextchar Either
            thischar    = 66; // "B"
            nextchar    = 66;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar Either
            thischar    = 1; // "^A"
            nextchar    = 66;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar Either
            thischar    = 110; // "n"
            nextchar    = 66;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cSHIFT, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");



            // in CodeA, thischar Either, nextchar -1
            thischar    = 66; // "B"
            nextchar    = -1;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar -1
            thischar    = 1; // "^A"
            nextchar    = -1;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar -1
            thischar    = 110; // "n"
            nextchar    = -1;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cSHIFT, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");



            // in CodeA, thischar Either, nextchar CodeA
            thischar    = 66; // "B"
            nextchar    = 1;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar CodeA
            thischar    = 1; // "^A"
            nextchar    = 1;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar CodeA
            thischar    = 110; // "n"
            nextchar    = 1;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cSHIFT, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");



            // in CodeA, thischar Either, nextchar CodeB
            thischar    = 66; // "B"
            nextchar    = 110;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar CodeB
            thischar    = 1; // "^A"
            nextchar    = 110;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar CodeB
            thischar    = 110; // "n"
            nextchar    = 110;
            currcs      = CodeSet.CodeA;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cCODEB, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreNotEqual(origcs, currcs, "Incorrect code set returned");



            // in CodeB, thischar Either, nextchar Either
            thischar    = 66; // "B"
            nextchar    = 66;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar Either
            thischar    = 1; // "^A"
            nextchar    = 66;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cSHIFT, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar Either
            thischar    = 110; // "n"
            nextchar    = 66;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");



            // in CodeB, thischar Either, nextchar -1
            thischar    = 66; // "B"
            nextchar    = -1;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar -1
            thischar    = 1; // "^A"
            nextchar    = -1;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cSHIFT, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar -1
            thischar    = 110; // "n"
            nextchar    = -1;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");



            // in CodeB, thischar Either, nextchar CodeA
            thischar    = 66; // "B"
            nextchar    = 1;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar CodeA
            thischar    = 1; // "^A"
            nextchar    = 1;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cCODEA, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreNotEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar CodeA
            thischar    = 110; // "n"
            nextchar    = 1;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");



            // in CodeB, thischar Either, nextchar CodeB
            thischar    = 66; // "B"
            nextchar    = 110;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar CodeB
            thischar    = 1; // "^A"
            nextchar    = 110;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(cSHIFT, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar CodeB
            thischar    = 110; // "n"
            nextchar    = 110;
            currcs      = CodeSet.CodeB;
            origcs      = currcs;
            resultcodes = Code128Code.CodesForChar(thischar, nextchar, ref currcs);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currcs, "Incorrect code set returned");
        }
Ejemplo n.º 5
0
        public void CharTranslationTests()
        {
            // in CodeA, thischar Either, nextchar Either
            var thischar       = 66;
            var nextchar       = 66;
            var currentCodeSet = CodeSet.CodeA;
            var origcs         = currentCodeSet;
            var resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);

            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar Either
            thischar       = 1; // "^A"
            nextchar       = 66;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar Either
            thischar       = 110; // "n"
            nextchar       = 66;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CShift, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar Either, nextchar -1
            thischar       = 66; // "B"
            nextchar       = -1;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar -1
            thischar       = 1; // "^A"
            nextchar       = -1;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar -1
            thischar       = 110; // "n"
            nextchar       = -1;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CShift, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar Either, nextchar CodeA
            thischar       = 66; // "B"
            nextchar       = 1;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar CodeA
            thischar       = 1; // "^A"
            nextchar       = 1;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar CodeA
            thischar       = 110; // "n"
            nextchar       = 1;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CShift, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar Either, nextchar CodeB
            thischar       = 66; // "B"
            nextchar       = 110;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeA, nextchar CodeB
            thischar       = 1; // "^A"
            nextchar       = 110;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(65, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeA, thischar CodeB, nextchar CodeB
            thischar       = 110; // "n"
            nextchar       = 110;
            currentCodeSet = CodeSet.CodeA;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CCodeB, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(78, resultcodes[1], "Incorrect code returned");
            Assert.AreNotEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar Either, nextchar Either
            thischar       = 66; // "B"
            nextchar       = 66;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar Either
            thischar       = 1; // "^A"
            nextchar       = 66;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CShift, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar Either
            thischar       = 110; // "n"
            nextchar       = 66;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar Either, nextchar -1
            thischar       = 66; // "B"
            nextchar       = -1;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar -1
            thischar       = 1; // "^A"
            nextchar       = -1;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CShift, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar -1
            thischar       = 110; // "n"
            nextchar       = -1;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar Either, nextchar CodeA
            thischar       = 66; // "B"
            nextchar       = 1;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar CodeA
            thischar       = 1; // "^A"
            nextchar       = 1;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CCodeA, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreNotEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar CodeA
            thischar       = 110; // "n"
            nextchar       = 1;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar Either, nextchar CodeB
            thischar       = 66; // "B"
            nextchar       = 110;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(34, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeA, nextchar CodeB
            thischar       = 1; // "^A"
            nextchar       = 110;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(2, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(CShift, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(65, resultcodes[1], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");

            // in CodeB, thischar CodeB, nextchar CodeB
            thischar       = 110; // "n"
            nextchar       = 110;
            currentCodeSet = CodeSet.CodeB;
            origcs         = currentCodeSet;
            resultcodes    = Code128Code.CodesForChar(thischar, nextchar, ref currentCodeSet);
            Assert.IsNotNull(resultcodes, "No codes returned");
            Assert.AreEqual(1, resultcodes.Length, "Incorrect number of codes returned");
            Assert.AreEqual(78, resultcodes[0], "Incorrect code returned");
            Assert.AreEqual(origcs, currentCodeSet, "Incorrect code set returned");
        }