I have to calculate a checksum digit for a barcode of type Code128 in C#, similar to this post: https://support.idautomation.com/Code-128/Manually-calculate-check-digit-for-Code-128/_1025
I read this page which gives some calculation examples: https://www.barcodefaq.com/1d/code-128/#CalculationExamples
It states the basic steps of the algorithm:
- Reference the character set table to obtain the value of the start character and all data characters.
- Assign a weight to each data character (not the start character, just the data characters.) The weighting starts at 1 and increases by one for each data character.
- Multiply the character values by their weights for the data characters.
- Add these together including the start character, divide by 103 and obtain the remainder.
- Use the character set table to locate the character that has the value of the remainder, use this as the check character.
I understood this description in general, but I am not sure how to implement the part "Reference the character set table to obtain the value of ... the character"
May question is: How can a write code that gets a value for a certain character depending on whether I want the checksum according to version / codeset A, B or C of the Code128 character set? https://www.barcodefaq.com/1d/code-128/#Code-128CharacterSet
Do I have to re-create the table with the character set in code (as a big dictionary?) or can I just perform some easy calculation to get the value for a character for Code128 version / CodeSet A, B, or c?
How should I implement this methods?
private uint GetValueForCode128Character_CodeSetA(char character)
{
}
private uint GetValueForCode128Character_CodeSetB(char character)
{
}
private uint GetValueForCode128Character_CodeSetC(char character)
{
}
I also read the answer to this question: Is this code for calculating Code128 barcode check digits correct?
But that seems to refer to the algorithm in general (which I understand) and less on getting that value for certain character depending on the Code128 codeset A,B or A.
Thank you for your time.