Spire.Barcode is a professional barcode library specially designed for .NET developers (C#, VB.NET, ASP.NET, .NET Core) and Java developers (J2SE and J2EE) to generate, read and scan 1D & 2D barcodes.

Wed Jul 20, 2022 6:34 am

Hello,

i need to create a QR-Code with UTF-8 encoding for creating a swiss QR-Bill.

The created QR-Code can be validated via a website, but i'm not allowed to post URLs :(

The image of the code can simply be inserted by drag and drop.

A Sample created from my code is added as an attachment "test.png"

The Problem is, that german special charachters are not readed correct.

I'm using the following code snipped to create the barcode:
The convertion to utf8 is from microsoft.

Code: Select all
        Dim unicodeString = "äüö?'#'ßÄÖÜ"

        Dim unicodeBytes = Encoding.Unicode.GetBytes(unicodeString)

        Dim utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, unicodeBytes)

        Dim utf8Chars(Encoding.UTF8.GetCharCount(utf8Bytes, 0, utf8Bytes.Length - 1)) As Char
        Encoding.UTF8.GetChars(utf8Bytes,0,utf8Bytes.Length,utf8Chars,0)
        Dim utf8String As New String(utf8Chars)

        Dim settings As New BarcodeSettings()

        settings.Type = BarCodeType.QRCode
        settings.QRCodeDataMode = QRCodeDataMode.Byte

        settings.QRCodeECL = QRCodeECL.H
        settings.X = 2.0F

        settings.Data = utf8String
        settings.Data2D = utf8String

        Dim generator As New BarCodeGenerator(settings)

        Dim image = generator.GenerateImage()
        image.Save("test.png")



I'm using the latest version 6.6.3 of spire.barcode.

Did I miss any settings or something else to create a correct utf-8 encoded QR-code?

andys1904
 
Posts: 1
Joined: Wed Jul 20, 2022 6:15 am

Wed Jul 20, 2022 10:10 am

Hello,

Thanks for your inquiry.

I tested your code and got garbled characters when scaning the barcode. I also found something strange. If I add some Chinese characters into the string, then all of the characters will be read correctly. Such as below.
Code: Select all
Dim unicodeString = "äüö?'#'ßÄÖÜ中"

I have logged this issue in our bug tracking system with the ticket SPIREBARCODE-218 for further investigation. I will notify you in time if there is any update about it. Sorry for the inconvenience caused.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.BarCode