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!

129 Comments

  1. Pingback: dizain-cheloveka-manifestor.ru

  2. Pingback: hdmy.ru

  3. Pingback: HumanDesign2028.ru

  4. Pingback: cenforce 200

  5. Pingback: buy cenforce 200 mg online

  6. Pingback: vardenafil

  7. Pingback: canadian pharmacy in tampa fl

  8. Pingback: where can i buy Azithromycin

  9. Pingback: cost of clomid without prescription

  10. Pingback: kamagra usa ban

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

  12. Pingback: lasix 100mg over the counter

  13. Pingback: Ventolin inhaler how often to use

  14. Pingback: buy viagra online

  15. Pingback: ivecop tablet

  16. Pingback: buy priligy paypal

  17. Pingback: androgel 1.0

  18. Pingback: my canadian pharmacy reviews

  19. Pingback: youtube-videos

  20. Pingback: viagra pfizer 50 mg

  21. Pingback: no presciption cialis

  22. Pingback: 60 mg cialis

  23. Pingback: cialis in canada

  24. Pingback: buy viagra 50 mg

  25. Pingback: viagra 75 mg

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

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

  28. Pingback: dizain cheloveka

  29. Pingback: sulfatealbuterol.com

  30. Pingback: ivermectinus.com

  31. Pingback: human design

  32. Pingback: axbb.ru

  33. Pingback: cenforcemg.com

  34. Pingback: flagylzub.com

  35. Pingback: kmgra.com

  36. Pingback: lasixotc.com

  37. Pingback: stromectool.com

  38. Pingback: flagyltb.com

  39. Pingback: levitraoffer.net

  40. Pingback: priligy 30mg

  41. Pingback: tiktok

  42. Pingback: hyocimax s tablet uses

  43. Pingback: can i buy amoxicillin

  44. Pingback: nitrostat pill

  45. Pingback: ciprodex dosage

  46. Pingback: groups

  47. Pingback: cheapest viagra 50mg

  48. Pingback: amoxil for urinary tract infection

  49. Pingback: cialis online prices

  50. Pingback: purple viagra 100

  51. Pingback: prednisolone dose for asthma

  52. Pingback: blood pressure bystolic

  53. Pingback: amoxil capsule price

  54. Pingback: professorkorotkov.ru

  55. Pingback: viahelpmen.wordpress.com

  56. Pingback: psycholog-korotkov.ru

  57. Pingback: vermact plus

  58. Pingback: clomid for sale

  59. Pingback: psikhologvyalte.ru

  60. Pingback: clincitop gel buy online

  61. Pingback: besivance eye drop prices

  62. Pingback: buy assurans

  63. Pingback: here

  64. Pingback: caverta 25

  65. Pingback: super tadalista

  66. Pingback: kamagra uk

  67. Pingback: vidalista.pics

  68. Pingback: otclevitra.com

  69. Pingback: clomiphene Citrate

  70. Pingback: ekzistenczialnyj

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

  72. Pingback: prednisone 20mg

  73. Pingback: clomid for sale

  74. Pingback: 75mg viagra

  75. Pingback: myprin92.ru

  76. Pingback: 0410.ru

  77. Pingback: atvip.ru

  78. Pingback: vigrakrs.com

  79. Pingback: why take latanoprost at night

  80. Pingback: sketchfab.com/female-cialis

  81. Pingback: 5yucMCMAAAAJ

  82. Pingback: instagram.com/korotkovlakanfreud

  83. Pingback: ofevinfo.wordpress.com

  84. Pingback: site

  85. Pingback: price of viagra per pill

  86. Pingback: samscainfo.wordpress.com

  87. Pingback: vidalforman.wordpress.com

  88. Pingback: Sochi-psiholog-Russia

  89. Pingback: who makes viagra pills

  90. Pingback: vardenafil 20mg

  91. Pingback: 100 mg viagra side effects

  92. Pingback: t.me/s/psy_chat_online

  93. Pingback: clomiphene 50mg ovulation

  94. Pingback: afinitor cost

  95. Pingback: Forum

  96. Pingback: fildena.homes

  97. Pingback: 439W6fo

  98. Pingback: psy

  99. Pingback: r2f.ru

  100. Pingback: xblx.ru

  101. Pingback: dilts.g-u.su

  102. Pingback: anatoliy-alekseyevich-derkach.ru

  103. Pingback: where to buy cheap toradol for sale

  104. Pingback: artane and coolock credit union

  105. Pingback: zanaflex for sciatica pain

  106. Pingback: cyproheptadine hydrochloride syrup ip side effects

  107. Pingback: street value of tizanidine 2mg

  108. Pingback: periactin sciroppo dosaggio

  109. Pingback: can you get generic ketorolac pills

  110. Pingback: baclofen compared to vicodin

  111. Pingback: azathioprine irregular heartbeat

  112. Pingback: maxalt wine

  113. Pingback: classe terapeutica piroxicam

  114. Pingback: how effective is meloxicam for pain

  115. Pingback: prospecto de lioresal

  116. Pingback: imdur pill

  117. Pingback: what are side effects of mobic

  118. Pingback: imuran proctitis

  119. Pingback: rizatriptan benzoate drug bank

  120. Pingback: can you take sumatriptan and paracetamol together

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

  122. Pingback: diclofenac vs celebrex

  123. Pingback: cilostazol en insuficiencia cardiaca

  124. Pingback: can mebeverine be taken after food

  125. Pingback: indomethacin 75 sr

  126. Pingback: migraine injection imitrex

  127. Pingback: amitriptyline dose for sleep

  128. Pingback: mestinon tabs

  129. Pingback: elavil mgs

Leave a Comment