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

Code 128 encoding is broken for some payloads containing "99" #184

Closed
MarredCheese opened this issue Dec 13, 2023 · 6 comments
Closed

Code 128 encoding is broken for some payloads containing "99" #184

MarredCheese opened this issue Dec 13, 2023 · 6 comments

Comments

@MarredCheese
Copy link

In v3.0.0 and v3.0.3, Code128 generates incorrect barcodes for certain payloads. In my experience, the payloads that provoke the bug always involve the text "99". I included some examples at the bottom.

public static Image MakeBarcodeImage(string text)
{
    Barcode encoder = new Barcode();
    SKImage skImage = encoder.Encode(BarcodeStandard.Type.Code128, text);
    Stream imageStream = skImage.Encode().AsStream();
    return Image.FromStream(imageStream);
}

If I force it to use only code set B, it works fine:

SKImage skImage = encoder.Encode(BarcodeStandard.Type.Code128B, text);

If I downgrade to v2.4.0, it also works fine:

public static Image MakeBarcodeImage(string text)
{
    Barcode encoder = new Barcode();
    return encoder.Encode(TYPE.CODE128, text);
}

Some bad barcodes

Input Text Text in Resulting Barcode
Q99 Q
Q990 Q16
Q991 Q17
Q992 Q18
Q993 Q19
Q994 Q20
Q995 Q21
Q996 Q22
Q997 Q23
Q998 Q24
Q999 Q25
Q9999 Q99
Q99990 Q9916
Q99991 Q9917
Q99992 Q9918
Q99993 Q9919
Q99994 Q9920
Q99995 Q9921
Q99996 Q9922
Q99997 Q9923
Q99998 Q9924
Q99999 Q9925
N0.99 N0.
N1.99 N1.
N10.99 N10.
N100.99 N100.
N101.99 N101.
N102.99 N102.
N103.99 N103.
N104.99 N104.
N105.99 N105.
N106.99 N106.
N107.99 N107.
N108.99 N108.
N109.99 N109.
N11.99 N11.
N110.99 N110.
N111.99 N111.
N112.99 N112.
N113.99 N113.
N114.99 N114.
N115.99 N115.
N116.99 N116.
N117.99 N117.
N118.99 N118.
N119.99 N119.
N12.99 N12.
N120.99 N120.
N121.99 N121.
N122.99 N122.
N123.99 N123.
N124.99 N124.
N125.99 N125.
N126.99 N126.
N127.99 N127.
N128.99 N128.
N129.99 N129.
N13.99 N13.
N130.99 N130.
N131.99 N131.
N132.99 N132.
N133.99 N133.
N134.99 N134.
N135.99 N135.
N136.99 N136.
N137.99 N137.
N138.99 N138.
N139.99 N139.
N14.99 N14.
N140.99 N140.
N141.99 N141.
N142.99 N142.
N143.99 N143.
N144.99 N144.
N145.99 N145.
N146.99 N146.
N147.99 N147.
N148.99 N148.
N149.99 N149.
N15.99 N15.
N16.99 N16.
N17.99 N17.
N18.99 N18.
N19.99 N19.
N2.99 N2.
N20.99 N20.
N21.99 N21.
N22.99 N22.
N23.99 N23.
N24.99 N24.
N25.99 N25.
N26.99 N26.
N27.99 N27.
N28.99 N28.
N29.99 N29.
N3.99 N3.
N30.99 N30.
N31.99 N31.
N32.99 N32.
N33.99 N33.
N34.99 N34.
N35.99 N35.
N36.99 N36.
N37.99 N37.
N38.99 N38.
N39.99 N39.
N4.99 N4.
N40.99 N40.
N41.99 N41.
N42.99 N42.
N43.99 N43.
N44.99 N44.
N45.99 N45.
N46.99 N46.
N47.99 N47.
N48.99 N48.
N49.99 N49.
N5.99 N5.
N50.99 N50.
N51.99 N51.
N52.99 N52.
N53.99 N53.
N54.99 N54.
N55.99 N55.
N56.99 N56.
N57.99 N57.
N58.99 N58.
N59.99 N59.
N6.99 N6.
N60.99 N60.
N61.99 N61.
N62.99 N62.
N63.99 N63.
N64.99 N64.
N65.99 N65.
N66.99 N66.
N67.99 N67.
N68.99 N68.
N69.99 N69.
N7.99 N7.
N70.99 N70.
N71.99 N71.
N72.99 N72.
N73.99 N73.
N74.99 N74.
N75.99 N75.
N76.99 N76.
N77.99 N77.
N78.99 N78.
N79.99 N79.
N8.99 N8.
N80.99 N80.
N81.99 N81.
N82.99 N82.
N83.99 N83.
N84.99 N84.
N85.99 N85.
N86.99 N86.
N87.99 N87.
N88.99 N88.
N89.99 N89.
N9.99 N9.
N90.99 N90.
N91.99 N91.
N92.99 N92.
N93.99 N93.
N94.99 N94.
N95.99 N95.
N96.99 N96.
N97.99 N97.
N98.99 N98.
N99.00 N149900
N99.01 N149901
N99.02 N149902
N99.03 N149903
N99.04 N149904
N99.05 N149905
N99.06 N149906
N99.07 N149907
N99.08 N149908
N99.09 N149909
N99.10 N149910
N99.11 N149911
N99.12 N149912
N99.13 N149913
N99.14 N149914
N99.15 N149915
N99.16 N149916
N99.17 N149917
N99.18 N149918
N99.19 N149919
N99.20 N149920
N99.21 N149921
N99.22 N149922
N99.23 N149923
N99.24 N149924
N99.25 N149925
N99.26 N149926
N99.27 N149927
N99.28 N149928
N99.29 N149929
N99.30 N149930
N99.31 N149931
N99.32 N149932
N99.33 N149933
N99.34 N149934
N99.35 N149935
N99.36 N149936
N99.37 N149937
N99.38 N149938
N99.39 N149939
N99.40 N149940
N99.41 N149941
N99.42 N149942
N99.43 N149943
N99.44 N149944
N99.45 N149945
N99.46 N149946
N99.47 N149947
N99.48 N149948
N99.49 N149949
N99.50 N149950
N99.51 N149951
N99.52 N149952
N99.53 N149953
N99.54 N149954
N99.55 N149955
N99.56 N149956
N99.57 N149957
N99.58 N149958
N99.59 N149959
N99.60 N149960
N99.61 N149961
N99.62 N149962
N99.63 N149963
N99.64 N149964
N99.65 N149965
N99.66 N149966
N99.67 N149967
N99.68 N149968
N99.69 N149969
N99.70 N149970
N99.71 N149971
N99.72 N149972
N99.73 N149973
N99.74 N149974
N99.75 N149975
N99.76 N149976
N99.77 N149977
N99.78 N149978
N99.79 N149979
N99.80 N149980
N99.81 N149981
N99.82 N149982
N99.83 N149983
N99.84 N149984
N99.85 N149985
N99.86 N149986
N99.87 N149987
N99.88 N149988
N99.89 N149989
N99.90 N149990
N99.91 N149991
N99.92 N149992
N99.93 N149993
N99.94 N149994
N99.95 N149995
N99.96 N149996
N99.97 N149997
N99.98 N149998
N99.99 N1499
N99.0 N1416
N99.1 N1417
N99.2 N1418
N99.3 N1419
N99.4 N1420
N99.5 N1421
N99.6 N1422
N99.7 N1423
N99.8 N1424
N99.9 N1425
N990.0 N161416
N990.1 N161417
N990.2 N161418
N990.3 N161419
N990.4 N161420
N990.5 N161421
N990.6 N161422
N990.7 N161423
N990.8 N161424
N990.9 N161425
N991.0 N171416
N991.1 N171417
N991.2 N171418
N991.3 N171419
N991.4 N171420
N991.5 N171421
N991.6 N171422
N991.7 N171423
N991.8 N171424
N991.9 N171425
N992.0 N181416
N992.1 N181417
N992.2 N181418
N992.3 N181419
N992.4 N181420
N992.5 N181421
N992.6 N181422
N992.7 N181423
N992.8 N181424
N992.9 N181425
N993.0 N191416
N993.1 N191417
N993.2 N191418
N993.3 N191419
N993.4 N191420
N993.5 N191421
N993.6 N191422
N993.7 N191423
N993.8 N191424
N993.9 N191425
N994.0 N201416
N994.1 N201417
N994.2 N201418
N994.3 N201419
N994.4 N201420
N994.5 N201421
N994.6 N201422
N994.7 N201423
N994.8 N201424
N994.9 N201425
N995.0 N211416
N995.1 N211417
N995.2 N211418
N995.3 N211419
N995.4 N211420
N995.5 N211421
N995.6 N211422
N995.7 N211423
N995.8 N211424
N995.9 N211425
N996.0 N221416
N996.1 N221417
N996.2 N221418
N996.3 N221419
N996.4 N221420
N996.5 N221421
N996.6 N221422
N996.7 N221423
N996.8 N221424
N996.9 N221425
N997.0 N231416
N997.1 N231417
N997.2 N231418
N997.3 N231419
N997.4 N231420
N997.5 N231421
N997.6 N231422
N997.7 N231423
N997.8 N231424
N997.9 N231425
N998.0 N241416
N998.1 N241417
N998.2 N241418
N998.3 N241419
N998.4 N241420
N998.5 N241421
N998.6 N241422
N998.7 N241423
N998.8 N241424
N998.9 N241425
N999.0 N251416
N999.1 N251417
N999.2 N251418
N999.3 N251419
N999.4 N251420
N999.5 N251421
N999.6 N251422
N999.7 N251423
N999.8 N251424
N999.9 N251425
@gambgia
Copy link

gambgia commented Mar 6, 2024

Hi, I have exactly the same issue with version 3.0.3 in .NET 8, generating a Code128 barcode.
When I generate a barcode with this text 'V991R-NEUTRA-SPE023-YD433' the generated barcode is readable, but the read value is: 'V1750134637535250331351483799023-YD433'.
I can also confirm the setting a CODE128B results in the right value decoded.
My code is very similar to the one reported by @MarredCheese (many thanks for all your tests)

@barnhill
Copy link
Owner

barnhill commented Apr 6, 2024

This is interesting. I just tested the java version of this lib and it doesnt have this issue. Let me try the .NET verison.

@vrapp
Copy link

vrapp commented May 23, 2024

I confirm the same problem, and indeed "99" appears to be the key. For the message ^750-993/1 it generated barcode with 750-191517 , although the label read ^750-993/1. This is version 3.1.1 and all previous since 3. Version 2.4.0 generated it correctly. .Net Framework 4.8.1

@barnhill
Copy link
Owner

I think this will fix the issue here. The issue was related to when it was trying to switch code types. PR here: #205

@barnhill
Copy link
Owner

@barnhill
Copy link
Owner

Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants