public string GetCode128A(string inputData) { string result = ""; int checksum = 103; int j = 1; for (int ii = 0; ii < inputData.Length; ii++) { if (inputData[ii] >= 32) { checksum += (inputData[ii] - 32) * (ii + 1); } else { checksum += (inputData[ii] + 64) * (ii + 1); } } checksum = checksum % 103; if (checksum < 95) { checksum += 32; } else { checksum += 100; } result = Convert.ToChar(203) + inputData.ToString() + Convert.ToChar(checksum) + Convert.ToChar(206); return result; }
public string GetCode128B(string inputData) { string result = ""; int checksum = 104; int j = 1; for (int ii = 0; ii < inputData.Length; ii++) { if (inputData[ii] >= 32) { checksum += (inputData[ii] - 32) * (ii + 1); } else { checksum += (inputData[ii] + 64) * (ii + 1); } } checksum = checksum % 103; if (checksum < 95) { checksum += 32; } else { checksum += 100; } result = Convert.ToChar(204) + inputData.ToString() + Convert.ToChar(checksum) + Convert.ToChar(206); return result; }
public static string GetCode128C(string inputData) { string result = ""; int checksum = 105; int j = 1; for (int ii = 0; ii < inputData.Length; ii++) { if (ii % 2 == 0) { checksum += Convert.ToInt32(inputData.Substring(ii, 2)) * j; if (Convert.ToInt32(inputData.Substring(ii, 2)) < 95) { result += Convert.ToChar(Convert.ToInt32(inputData.Substring(ii, 2)) + 32); } else { result += Convert.ToChar(Convert.ToInt32(inputData.Substring(ii, 2)) + 100); } j++; } ii++; } checksum = checksum % 103; if (checksum < 95) { checksum += 32; } else { checksum += 100; } result = Convert.ToChar(205) + result + Convert.ToChar(checksum) + Convert.ToChar(206); return result; }
public static function GetCode128C($inputData){ $result = ""; $checksum = 105; $j = 1; for ($ii = 0; $ii < strlen($inputData); $ii++) { if ($ii % 2 == 0) { //$checksum += Convert.ToInt32($inputData.Substring($ii, 2)) * $j; $checksum += intval(substr($inputData, $ii, 2)) * $j; if (intval(substr($inputData, $ii, 2)) < 95) { $result += strval(intval(substr($inputData, $ii, 2)) + 32); } else { $result += strval(intval(substr($inputData, $ii, 2)) + 100); } $j++; } $ii++; } $checksum = $checksum % 103; if ($checksum < 95) { $checksum += 32; } else { $checksum += 100; } $result = strval(205) . $result . strval($checksum) . strval(206); return $result;}