📄 barcode.txt
字号:
{
CheckDigit = 43;
}
else if(CheckDigitValue == 42) // %
{
CheckDigit = 37;
}
// Get Printable String
sprintf(PrintableString,"*%s%c*", strupr(DataToPrint), CheckDigit);
iSize = (long)strlen(PrintableString);
strncpy(output, PrintableString, strlen(PrintableString));
return 0;
}
/*****************************************************************/
/* ANSI C Functions for IDAutomation Barcode Fonts */
/* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
/* All rights reserved. */
/* Redistribution and use of this code in source and/or binary */
/* forms, with or without modification, are permitted provided */
/* that: (1) all copies of the source code retain the above */
/* unmodified copyright notice and this entire unmodified */
/* section of text, (2) You or Your organization owns a valid */
/* Developer License to this product from IDAutomation.com */
/* and, (3) when any portion of this code is bundled in any */
/* form with an application, a valid notice must be provided */
/* within the user documentation, start-up screen or in the */
/* help-about section of the application that specifies */
/* IDAutomation.com as the provider of the Software bundled */
/* with the application. */
/*****************************************************************/
long IDAutomation_Code93(char *DataToEncode, char *output, long iSize)
{
if(DataToEncode == NULL)
return 1;
if(strlen(DataToEncode) == 0)
return 1;
//char DataToEncode2[512];
//DataToEncode2 = new char[512];
char DataToPrint[512];
//DataToPrint = new char[512];
char PrintableString[512];
//PrintableString = new char[512];
int I;
char CurrentChar;
char CurrentValue;
char CheckDigitC;
char CheckDigitK;
char CheckDigitValue;
int CW = 1;
int KW = 2;
int CWSum =0;
int KWSum =0;
int bufferCounter = 0;
/* Get data from user, this is the DataToEncode */
//sprintf(DataToEncode2,"%s",strupr(DataToEncode));
/* only pass correct data */
for(I = 1;I <= (int)strlen(DataToEncode);I++)
{
/* Get each character one at a time */
CurrentChar = asc(strupr(mid(DataToEncode,I,1)));
/* Get the value of CurrentChar according to MOD43 */
/* 0-9 */
if(CurrentChar < 58 && CurrentChar > 47)
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = CurrentChar - 48;
}
else if(CurrentChar < 91 && CurrentChar > 64)
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = CurrentChar - 55;
}
else if(CurrentChar == 32) /* Space */
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", "=");
CurrentValue = 38;
}
else if(CurrentChar == 45) /* - */
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = 36;
}
else if(CurrentChar == 46) /* . */
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = 37;
}
else if(CurrentChar == 36) /* $ */
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = 39;
}
else if(CurrentChar == 47) /* / */
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = 40;
}
else if(CurrentChar == 43) /* + */
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = 41;
}
else if(CurrentChar == 37) /* % */
{
bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
CurrentValue = 42;
}
else
{
CurrentValue = 0;
}
/* To print the barcode symbol representing a space you will */
/* to type or print "=" (the equal character) instead of a space character.*/
if(CurrentChar == 32)
{
CurrentChar = 61;
}
}
for(I= (int)strlen(DataToEncode);I>0;I--)
{
/* Get each character one at a time */
CurrentChar=asc(strupr(mid(DataToEncode,I,1)));
/* Get the value of CurrentChar according to 93 */
if((CurrentChar<58)&&(CurrentChar>47))
/* 0-9 */
{
CurrentValue=CurrentChar-48;
}
/* A-Z */
if((CurrentChar<91)&&(CurrentChar>64))
{
CurrentValue=CurrentChar-55;
}
/* - */
if(CurrentChar==45)
{
CurrentValue=36;
}
/* . */
if(CurrentChar==46)
{
CurrentValue=37;
}
/* Space */
if(CurrentChar==32)
{
CurrentValue=38;
}
/* $ */
if(CurrentChar==36)
{
CurrentValue=39;
}
/* / */
if(CurrentChar==47)
{
CurrentValue=40;
}
/* + */
if(CurrentChar==43)
{
CurrentValue=41;
}
/* % */
if(CurrentChar==37)
{
CurrentValue=42;
}
/* ! */
if(CurrentChar==33 )
{
CurrentValue=43;
}
/* # */
if(CurrentChar==35 )
{
CurrentValue=44;
}
/* & */
if(CurrentChar==38 )
{
CurrentValue=45;
}
/* @ */
if(CurrentChar==64 )
{
CurrentValue=46;
}
CWSum += CurrentValue * CW;
KWSum += CurrentValue * KW;
if (CW == 20) {
CW = 0;
}
if (KW == 15) {
KW = 0;
}
CW++;
KW++;
}
/* divide the WeightedTotal by 47 and get the remainder, this is the CheckDigit for C */
CheckDigitValue = ((int)(CWSum % 47));
/* Assign values to characters for Check digit C */
/* 0-9 */
if(CheckDigitValue<10)
{
CheckDigitC=CheckDigitValue+48;
}
/* A-Z */
if((CheckDigitValue<36)&&(CheckDigitValue>9))
{
CheckDigitC=CheckDigitValue+55;
}
/* = */
if(CheckDigitValue==38)
{
CheckDigitC=61;
}
/* Space */
if(CheckDigitValue==38)
{
CheckDigitC=32;
}
/* - */
if(CheckDigitValue==36)
{
CheckDigitC=45;
}
/* . */
if(CheckDigitValue==37)
{
CheckDigitC=46;
}
/* $ */
if(CheckDigitValue==39)
{
CheckDigitC=36;
}
/* / */
if(CheckDigitValue==40)
{
CheckDigitC=47;
}
/* + */
if(CheckDigitValue==41)
{
CheckDigitC=43;
}
/* % */
if(CheckDigitValue==42)
{
CheckDigitC=37;
}
/* ! */
if(CheckDigitValue == 43 )
{
CheckDigitC=33;
}
/* # */
if(CheckDigitValue == 44 )
{
CheckDigitC=35;
}
/* & */
if(CheckDigitValue == 45 )
{
CheckDigitC=38;
}
/* @ */
if(CheckDigitValue == 46 )
{
CheckDigitC=64;
}
/* divide the WeightedTotal by 47 and get the remainder, this is the CheckDigit for K*/
CheckDigitValue = (int)((KWSum+CheckDigitValue) % 47);
/* 0-9 */
if(CheckDigitValue<10)
{
CheckDigitK=CheckDigitValue+48;
}
/* A-Z */
if((CheckDigitValue<36)&&(CheckDigitValue>9))
{
CheckDigitK=CheckDigitValue+55;
}
/* Space */
if(CheckDigitValue == 38)
{
CheckDigitK=32;
}
/* - */
if(CheckDigitValue == 36)
{
CheckDigitK=45;
}
/* . */
if(CheckDigitValue == 37)
{
CheckDigitK=46;
}
/* $ */
if(CheckDigitValue == 39)
{
CheckDigitK=36;
}
/* / */
if(CheckDigitValue == 40)
{
CheckDigitK=47;
}
/* + */
if(CheckDigitValue == 41)
{
CheckDigitK=43;
}
/* % */
if(CheckDigitValue == 42)
{
CheckDigitK=37;
}
/* ! */
if(CheckDigitValue == 43)
{
CheckDigitK=33;
}
/* # */
if(CheckDigitValue == 44)
{
CheckDigitK=35;
}
/* & */
if(CheckDigitValue == 45)
{
CheckDigitK=38;
}
/* @ */
if(CheckDigitValue == 46 )
{
CheckDigitK=64;
}
/* Get Printable String */
sprintf(PrintableString,"(%s%c%c)",strupr(DataToPrint),CheckDigitC,CheckDigitK);
iSize = (long)strlen(PrintableString);
strncpy(output, PrintableString, strlen(PrintableString));
return 0;
}
/*****************************************************************/
/* ANSI C Functions for IDAutomation Barcode Fonts */
/* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -