Adding support for reading 3 of 9 Extended barcodes (containing lowercase characters) with GdPicture9

Microsoft .NET

3 of 9 barcodes are just about everywhere, and are one of the easiest barcodes to work with being widely supported by many SDK's. 3 of 9 originally supported only a subset of the ASCII character set, and later was extended to support the full range of characters. Often you will find 3 of 9 barcodes in the form of a font style that you can use in word processors, web applications, and other types of software. They can be copy and pasted. They are easy to draw, and most importantly, they are very easy to understand. You can read more on Wikipedia about it, but lets talk more about how GdPicture SDK deals with it.

code39-sample

GdPicture does support drawing 3 of 9 barcodes with the extended character set using the Barcode1DWriterType.Barcode1DWriterCode39Extended enumeration with Barcode1DWrite, but I found that it lacked the ability to read them using Barcode1DReaderDoScan. If you look deeper into the enumerations available for these methods, oddly enough both Barcode1DWriterType.Barcode1DWriterCode39 and Barcode1DWriterType.Barcode1DWriterCode39Extended exist for drawing the barcode, but only Barcode1DReaderType.Barcode1DWriterCode39 exists for reading when using Barcode1DReaderDoScan.

gI_78908_LOGO-GD9

Now, let me clarify before we look at a solution. GdPicture does technically read the barcode with extended characters, but it doesn't actually return the extended ASCII characters. Instead, it returns each uppercase character prefixed with the + character, which is a token indicating the character casing, such as the sign in a signed integer. In the examples below we will look at the most common scenario which is support for lower case characters, which are only part of the extended character set.

string threeOfNine    = "ABC123"; // normal character set
string threeOfNineExt = "abc123"; // extended character set

These are the raw values you would normally expect to see when reading 3 of 9 barcodes using a proper SDK. In GdPicture however, let us take a look at the difference when reading the extended barcodes.

string threeOfNine    = "ABC123";    // normal character set
string threeOfNineExt = "+A+B+C123"; // extended character set

This pattern is very consistent, so we can write a simple function to parse and return the correct character casing.

/// <devdoc>
/// This method is for GdPicture9's lack of support for *reading* the 3 of 9 Extended character set,
/// which allows for lowercase characters. GdPicture will still return a barcode value, but each lower
/// case character is preceded by + character to indicate the casing difference.
/// 
/// ie. TEst (raw value of *TEst*) would be returned as TE+S+T (raw value of *TE+S+T*)
/// </devdoc>
private static string Get3Of9ExtendedBarcodeValue(string s)
{
    var newValue = string.Empty;

    for (int i = 0; i < s.Length; i++)
        if (s[i] == '+')
            newValue += s[++i].ToString(CultureInfo.InvariantCulture).ToLower();
        else
            newValue += s[i];

    return newValue.Replace("+", string.Empty);
}

The method is pretty straight forward, iterating over each character and identifying the token. When the token is found we do a forward lookup in the array, which will be the actual character value, and we know to return the lowercase value. We also increment the loop counter at the same time since we are processing that character. Otherwise if no token is found, we simply return the character as is.

Simple!

Now, I have only written this function to account for the casing differences between the character sets because that was the scenario I needed to solve for the project I was working on. I could have used other barcode libraries, but we already had licensing for GdPicture and it is significantly faster than most of the libraries out there, and I tested quite a few. I might revisit this blog at a later time and write a new one discussing the other extended characters, but for now we will leave it there.

Happy coding!

124 Comments

  1. Pingback: vardenafil

  2. Pingback: canadian pharmacy in tampa fl

  3. Pingback: where can i buy Azithromycin

  4. Pingback: cost of clomid without prescription

  5. Pingback: kamagra usa ban

  6. Pingback: +38 0950663759 – Владимир (Сергей) Романенко, Одесса – Оплатил предоплату — получил нерабочее устройство. Если СУКА не вернет деньги, обращаюсь в банк и поддержку OLX.

  7. Pingback: lasix 100mg over the counter

  8. Pingback: Ventolin inhaler how often to use

  9. Pingback: buy viagra online

  10. Pingback: ivecop tablet

  11. Pingback: buy priligy paypal

  12. Pingback: androgel 1.0

  13. Pingback: my canadian pharmacy reviews

  14. Pingback: youtube-videos

  15. Pingback: viagra pfizer 50 mg

  16. Pingback: no presciption cialis

  17. Pingback: 60 mg cialis

  18. Pingback: cialis in canada

  19. Pingback: buy viagra 50 mg

  20. Pingback: viagra 75 mg

  21. Pingback: experienceleaguecommunities.adobe.com/t5/user/viewprofilepage/user-id/17881217

  22. Pingback: in.pinterest.com/vidalista80review/

  23. Pingback: dizain cheloveka

  24. Pingback: sulfatealbuterol.com

  25. Pingback: ivermectinus.com

  26. Pingback: human design

  27. Pingback: axbb.ru

  28. Pingback: cenforcemg.com

  29. Pingback: flagylzub.com

  30. Pingback: kmgra.com

  31. Pingback: lasixotc.com

  32. Pingback: stromectool.com

  33. Pingback: flagyltb.com

  34. Pingback: levitraoffer.net

  35. Pingback: priligy 30mg

  36. Pingback: tiktok

  37. Pingback: hyocimax s tablet uses

  38. Pingback: can i buy amoxicillin

  39. Pingback: nitrostat pill

  40. Pingback: ciprodex dosage

  41. Pingback: groups

  42. Pingback: cheapest viagra 50mg

  43. Pingback: amoxil for urinary tract infection

  44. Pingback: cialis online prices

  45. Pingback: purple viagra 100

  46. Pingback: prednisolone dose for asthma

  47. Pingback: blood pressure bystolic

  48. Pingback: amoxil capsule price

  49. Pingback: professorkorotkov.ru

  50. Pingback: viahelpmen.wordpress.com

  51. Pingback: psycholog-korotkov.ru

  52. Pingback: vermact plus

  53. Pingback: clomid for sale

  54. Pingback: psikhologvyalte.ru

  55. Pingback: clincitop gel buy online

  56. Pingback: besivance eye drop prices

  57. Pingback: buy assurans

  58. Pingback: here

  59. Pingback: caverta 25

  60. Pingback: super tadalista

  61. Pingback: kamagra uk

  62. Pingback: vidalista.pics

  63. Pingback: otclevitra.com

  64. Pingback: clomiphene Citrate

  65. Pingback: ekzistenczialnyj

  66. Pingback: Ïñèõîëîã, ïñèõîòåðàïåâò, ïñèõèàòð, ïñèõîàíàëèòèê

  67. Pingback: prednisone 20mg

  68. Pingback: clomid for sale

  69. Pingback: 75mg viagra

  70. Pingback: myprin92.ru

  71. Pingback: 0410.ru

  72. Pingback: atvip.ru

  73. Pingback: vigrakrs.com

  74. Pingback: why take latanoprost at night

  75. Pingback: sketchfab.com/female-cialis

  76. Pingback: 5yucMCMAAAAJ

  77. Pingback: instagram.com/korotkovlakanfreud

  78. Pingback: ofevinfo.wordpress.com

  79. Pingback: site

  80. Pingback: price of viagra per pill

  81. Pingback: samscainfo.wordpress.com

  82. Pingback: vidalforman.wordpress.com

  83. Pingback: Sochi-psiholog-Russia

  84. Pingback: who makes viagra pills

  85. Pingback: vardenafil 20mg

  86. Pingback: 100 mg viagra side effects

  87. Pingback: t.me/s/psy_chat_online

  88. Pingback: clomiphene 50mg ovulation

  89. Pingback: afinitor cost

  90. Pingback: Forum

  91. Pingback: fildena.homes

  92. Pingback: 439W6fo

  93. Pingback: psy

  94. Pingback: r2f.ru

  95. Pingback: xblx.ru

  96. Pingback: dilts.g-u.su

  97. Pingback: anatoliy-alekseyevich-derkach.ru

  98. Pingback: where to buy cheap toradol for sale

  99. Pingback: artane and coolock credit union

  100. Pingback: zanaflex for sciatica pain

  101. Pingback: cyproheptadine hydrochloride syrup ip side effects

  102. Pingback: street value of tizanidine 2mg

  103. Pingback: periactin sciroppo dosaggio

  104. Pingback: can you get generic ketorolac pills

  105. Pingback: baclofen compared to vicodin

  106. Pingback: azathioprine irregular heartbeat

  107. Pingback: maxalt wine

  108. Pingback: classe terapeutica piroxicam

  109. Pingback: how effective is meloxicam for pain

  110. Pingback: prospecto de lioresal

  111. Pingback: imdur pill

  112. Pingback: what are side effects of mobic

  113. Pingback: imuran proctitis

  114. Pingback: rizatriptan benzoate drug bank

  115. Pingback: can you take sumatriptan and paracetamol together

  116. Pingback: where can i buy generic pyridostigmine without dr prescription

  117. Pingback: diclofenac vs celebrex

  118. Pingback: cilostazol en insuficiencia cardiaca

  119. Pingback: can mebeverine be taken after food

  120. Pingback: indomethacin 75 sr

  121. Pingback: migraine injection imitrex

  122. Pingback: amitriptyline dose for sleep

  123. Pingback: mestinon tabs

  124. Pingback: elavil mgs

Leave a Comment