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!

76 Comments

  1. Pingback: professorkorotkov.ru

  2. Pingback: viahelpmen.wordpress.com

  3. Pingback: psycholog-korotkov.ru

  4. Pingback: vermact plus

  5. Pingback: clomid for sale

  6. Pingback: psikhologvyalte.ru

  7. Pingback: clincitop gel buy online

  8. Pingback: besivance eye drop prices

  9. Pingback: buy assurans

  10. Pingback: here

  11. Pingback: caverta 25

  12. Pingback: super tadalista

  13. Pingback: kamagra uk

  14. Pingback: vidalista.pics

  15. Pingback: otclevitra.com

  16. Pingback: clomiphene Citrate

  17. Pingback: ekzistenczialnyj

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

  19. Pingback: prednisone 20mg

  20. Pingback: clomid for sale

  21. Pingback: 75mg viagra

  22. Pingback: myprin92.ru

  23. Pingback: 0410.ru

  24. Pingback: atvip.ru

  25. Pingback: vigrakrs.com

  26. Pingback: why take latanoprost at night

  27. Pingback: sketchfab.com/female-cialis

  28. Pingback: 5yucMCMAAAAJ

  29. Pingback: instagram.com/korotkovlakanfreud

  30. Pingback: ofevinfo.wordpress.com

  31. Pingback: site

  32. Pingback: price of viagra per pill

  33. Pingback: samscainfo.wordpress.com

  34. Pingback: vidalforman.wordpress.com

  35. Pingback: Sochi-psiholog-Russia

  36. Pingback: who makes viagra pills

  37. Pingback: vardenafil 20mg

  38. Pingback: 100 mg viagra side effects

  39. Pingback: t.me/s/psy_chat_online

  40. Pingback: clomiphene 50mg ovulation

  41. Pingback: afinitor cost

  42. Pingback: Forum

  43. Pingback: fildena.homes

  44. Pingback: 439W6fo

  45. Pingback: psy

  46. Pingback: r2f.ru

  47. Pingback: xblx.ru

  48. Pingback: dilts.g-u.su

  49. Pingback: anatoliy-alekseyevich-derkach.ru

  50. Pingback: where to buy cheap toradol for sale

  51. Pingback: artane and coolock credit union

  52. Pingback: zanaflex for sciatica pain

  53. Pingback: cyproheptadine hydrochloride syrup ip side effects

  54. Pingback: street value of tizanidine 2mg

  55. Pingback: periactin sciroppo dosaggio

  56. Pingback: can you get generic ketorolac pills

  57. Pingback: baclofen compared to vicodin

  58. Pingback: azathioprine irregular heartbeat

  59. Pingback: maxalt wine

  60. Pingback: classe terapeutica piroxicam

  61. Pingback: how effective is meloxicam for pain

  62. Pingback: prospecto de lioresal

  63. Pingback: imdur pill

  64. Pingback: what are side effects of mobic

  65. Pingback: imuran proctitis

  66. Pingback: rizatriptan benzoate drug bank

  67. Pingback: can you take sumatriptan and paracetamol together

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

  69. Pingback: diclofenac vs celebrex

  70. Pingback: cilostazol en insuficiencia cardiaca

  71. Pingback: can mebeverine be taken after food

  72. Pingback: indomethacin 75 sr

  73. Pingback: migraine injection imitrex

  74. Pingback: amitriptyline dose for sleep

  75. Pingback: mestinon tabs

  76. Pingback: elavil mgs

Leave a Comment