Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Start Char Issue with C128 Dynamic #205

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions BarcodeStandard/Symbologies/Code128.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ private void InsertStartandCodeCharacters()
try
{
Dictionary<string, int> col = null;
var currentStartCode = "";

for (var i = 0; i < _FormattedData.Count; i++)
{
Expand All @@ -368,9 +369,9 @@ private void InsertStartandCodeCharacters()
var sameCodeSet = false;
foreach (var row in tempStartChars)
{
if (C128_CodeIndexByA.TryGetValue(currentElement, out var index) && index == row
|| C128_CodeIndexByB.TryGetValue(currentElement, out index) && index == row
|| C128_CodeIndexByC.TryGetValue(currentElement, out index) && index == row)
if ((C128_CodeIndexByA.ContainsKey(currentElement) && currentStartCode == "START_A")
|| (C128_CodeIndexByB.ContainsKey(currentElement) && currentStartCode == "START_B")
|| (C128_CodeIndexByC.ContainsKey(currentElement) && currentStartCode == "START_C"))
{
sameCodeSet = true;
break;
Expand All @@ -396,6 +397,7 @@ private void InsertStartandCodeCharacters()
if (CurrentCodeSet == C128_CodeIndexByA[start])
{
col = nextCol;
currentStartCode = start;
_FormattedData.Insert(i++, start);
break;
}
Expand All @@ -406,6 +408,7 @@ private void InsertStartandCodeCharacters()
if (col != nextCol && CurrentCodeSet == col[code])
{
col = nextCol;
currentStartCode = start;
_FormattedData.Insert(i++, code);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion BarcodeStandardTests/Symbologies/Code128Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Code128Tests
[DataRow("12094568792", "1101001110010110011100110010010001011101100010000100110100011110101110101111011001110010110111001001100011101011", "110100001001001110011011001110010100111011001110010110011001001110110111001001100111010011101001100111011011101110010110011001110010110110111101100011101011", "110100100001001110011011001110010100111011001110010110011001001110110111001001100111010011101001100111011011101110010110011001110010110111101101100011101011", "11010011100110011011001100100111010001011110111000101101111001010010101111000100010111101100011101011")]
[DataRow("121234349090", "11010011100101100111001011001110010001011000100010110001101111011011011110110110110110001100011101011", "11010000100100111001101100111001010011100110110011100101100101110011001001110110010111001100100111011100101100100111011001110010110010011101100100010111101100011101011", "11010010000100111001101100111001010011100110110011100101100101110011001001110110010111001100100111011100101100100111011001110010110010011101100101111010001100011101011", "11010011100101100111001011001110010001011000100010110001101111011011011110110110110110001100011101011")]
[DataRow("thisisalongerstring1212121212", "1101001000010011110100100110000101000011010010111100100100001101001011110010010010110000110010100001000111101011000010100100110100001011001000010010011110101111001001001111010010010011110100001101001100001010010011010000101110111101011001110010110011100101100111001011001110010110011100100011000101100011101011", null, "110100100001001111010010011000010100001101001011110010010000110100101111001001001011000011001010000100011110101100001010010011010000101100100001001001111010111100100100111101001001001111010000110100110000101001001101000010011100110110011100101001110011011001110010100111001101100111001010011100110110011100101001110011011001110010110001000101100011101011", null)]
[DataRow("fighting!", "1101001000010110000100100001101001001101000010011000010100111101001000011010011000010100100110100001110101111011001101100100100011001100011101011", null, "11010010000101100001001000011010010011010000100110000101001111010010000110100110000101001001101000011001101100110111001001100011101011", null)]
[DataRow("fighting!", "11010010000101100001001000011010010011010000100110000101001111010010000110100110000101001001101000011001101100110111001001100011101011", null, "11010010000101100001001000011010010011010000100110000101001111010010000110100110000101001001101000011001101100110111001001100011101011", null)]
[DataRow("파이팅!", null, null, null, null)]
[DataRow("ファイト!", null, null, null, null)]
[DataRow("\u0012", "1101000010010010011110100100111101100011101011", "1101000010010010011110100100111101100011101011", null, null)]
Expand Down