BarcodeLib/Symbologies/UPCA.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace BarcodeLib
{
class UPCA : BarcodeCommon, IBarcode
{
private string[] UPC_CodeA = { "0001101", "0011001", "0010011", "0111101", "0100011", "0110001", "0101111", "0111011", "0110111", "0001011" };
private string[] UPC_CodeB = { "0100111", "0110011", "0011011", "0100001", "0011101", "0111001", "0000101", "0010001", "0001001", "0010111" };
private string[] UPC_CodeC = { "1110010", "1100110", "1101100", "1000010", "1011100", "1001110", "1010000", "1000100", "1001000", "1110100" };
private string[] UPC_Pattern = { "aaaaaa", "aababb", "aabbab", "aabbba", "abaabb", "abbaab", "abbbaa", "ababab", "ababba", "abbaba" };
private string _Country_Assigning_Manufacturer_Code = "N/A";
private Hashtable CountryCodes = new Hashtable(); //is initialized by init_CountryCodes()
public UPCA(string input)
{
Raw_Data = input;
}
/// <summary>
/// Encode the raw data using the UPC-A algorithm.
/// </summary>
private string Encode_UPCA()
{
//check length of input
if (Raw_Data.Length != 12)
throw new Exception("EUPCA-1: Data length invalid.");
if (!BarcodeLib.Barcode.CheckNumericOnly(Raw_Data))
throw new Exception("EUPCA-2: Numeric Data Only");
string result = "101"; //start with guard bars
string patterncode = UPC_Pattern[Int32.Parse(Raw_Data[0].ToString())];
//first number
result += UPC_CodeA[Int32.Parse(Raw_Data[0].ToString())];
//second (group) of numbers
int pos = 0;
while (pos < 5)
{
if (patterncode[pos + 1] == 'a')
result += UPC_CodeA[Int32.Parse(Raw_Data[pos + 1].ToString())];
if (patterncode[pos + 1] == 'b')
result += UPC_CodeB[Int32.Parse(Raw_Data[pos + 1].ToString())];
pos++;
}//while
//add divider bars
result += "01010";
//third (group) of numbers
pos = 0;
while (pos < 5)
{
result += UPC_CodeC[Int32.Parse(Raw_Data[(pos++) + 6].ToString())];
}//while
//forth
后面还有 180 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。