Beispiel #1
0
        protected override string GetEncoding(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(string.Empty);
            }
            if (this.Checksum)
            {
                value += (string)(object)Code25.GetChecksum(value);
            }
            if (value.Length % 2 != 0)
            {
                value = Code25Interleaved.Padding + value;
            }
            if (!value.StartsWith(Code25Interleaved.Prefix))
            {
                value = Code25Interleaved.Prefix + value;
            }
            if (!value.EndsWith(Code25Interleaved.Suffix))
            {
                value += Code25Interleaved.Suffix;
            }
            StringBuilder stringBuilder = new StringBuilder();
            int           length;

            for (int startIndex = 0; startIndex < value.Length; startIndex += length)
            {
                length = !char.IsDigit(value[startIndex]) ? 1 : 2;
                string index = value.Substring(startIndex, length);
                stringBuilder.Append(Code25Interleaved.Encoding[index]);
            }
            return(stringBuilder.ToString());
        }
Beispiel #2
0
 protected static char GetChecksum(string value)
 {
     return(Code25.GetChecksum(value, 3, 1, 10));
 }