bardecode.com
barcode reading software
  • Home
  • Download
  • Purchase
  • SDK Licensing
  • Pricing
    • Windows SDK Price List
    • Windows SDK with PDF Extension Price List
    • Linux SDK Price List
    • Linux SDK with PDF Extension Price List
    • PDF Extension For Windows Price List
    • Multi-Platform Toolkit for .NET Price List
    • BardecodeFiler Desktop Only Price List
    • BardecodeFiler Windows Service Price List
    • DOS Command Prompt Barcode Tool Price List
    • Terms and Conditions
    • Refund Policy
  • Products
    • Softek Barcode Reader Toolkit for Windows
    • Softek Barcode Reader Toolkit for Linux
    • BardecodeFiler Desktop App
    • BardecodeFiler Windows Service
    • Windows DOS Command Prompt Tool
    • Multi-platform barcode reader toolkit for .NET
    • Aquaforest’s Autobahn DX
  • Knowledge Base
    • Documentation
    • Specifications
  • News
  • Contact
    • About Us
    • Terms and Conditions
    • Resellers
    • Links
Select Page ...

News

Handling Unicode Encoded Barcodes in VB.Net

admin November 26, 2012 Software Development Kits No Comments

2-D barcode formats such as PDF-417 can encode a huge character set, which means that the barcode reader toolkit needs to encode characters outside the normal ASCII range. If the Encoding property is set to 2 then the toolkit will use Unicode encoding, whereby characters can be represented by the string &#N; where N is an integer.

For example:

Ñ represents the character Ñ

To decode this to a unicode string in VB.Net you need to process the barcode value through a regular expression replacement as follows:

Step 1:

Create a function to convert the integer values (stored in a string) to a single character string holding the character represented by the unicode integer value…

Private Function MatchHandler(ByVal m As System.Text.RegularExpressions.Match) As String
Dim i As Int16
i = Int16.Parse(m.Groups(1).Value, Globalization.NumberStyles.Integer)
‘ Suppress null characters.
If i = 0 Then
Return “”
End If
Return Chr(i).ToString()
End Function

Step 2:

In the function where you read the barcode values:

‘ Get the barcode value
strBarcode = barcode.GetBarString(1)
‘ Create the delegate and the regular expression
Dim myDelegate As New System.Text.RegularExpressions.MatchEvaluator(AddressOf MatchHandler)
Dim re As New System.Text.RegularExpressions.Regex(“&#([0-9]+);”)
‘ Convert the Unicode escape sequences to a regular unicode string
strBarcode = re.Replace(strBarcode, myDelegate)

← Unicode problems in Delphi 2009
Code 39 barcodes with double start/stop patterns →
admin

  • Copyright © 2023 Softek Software Ltd. All Rights Reserved