Exemplo n.º 1
0
        private static BitList EncodeEan13(string content)
        {
            var result = new BitList();

            result.AddBit(true, false, true);
            bool[] firstNum = null;
            var    cpos     = 0;

            foreach (var r in content)
            {
                Constants.EncodedNumber num = Constants.EncodingTable[r];
                if (firstNum == null)
                {
                    firstNum = num.Checksum;
                    cpos++;
                    continue;
                }
                bool[] data = cpos < 7 ? firstNum[cpos - 1] ? num.LeftEven : num.LeftOdd : num.Right;
                if (cpos == 7)
                {
                    result.AddBit(false, true, false, true, false);
                }
                result.AddBit(data);
                cpos++;
            }
            result.AddBit(true, false, true);
            return(result);
        }
Exemplo n.º 2
0
        private static BitList EncodeEan8(string content)
        {
            var result = new BitList();

            result.AddBit(true, false, true);
            var cpos = 0;

            foreach (var r in content)
            {
                Constants.EncodedNumber num = Constants.EncodingTable[r];
                bool[] data = cpos < 4 ? num.LeftOdd : num.Right;
                if (cpos == 4)
                {
                    result.AddBit(false, true, false, true, false);
                }
                result.AddBit(data);
                cpos++;
            }
            result.AddBit(true, false, true);
            return(result);
        }