1

I am trying to use List & Label in my C# application to output a QR code in UTF-8 encoding. This is exactly what my customer needs.

Unfortunately, the customer's scanner only displays special characters. I can't find an option to set the charset for output. LL_OPTION_SAVE_PROJECT_IN_UTF8 seems to have no effect. I also tried to set LL_OPTION_CODEPAGE to no avail.

How can the QR code be output as UTF-8?

1
  • 1
    Probably you're trying to print the Swiss Invoice QR-Code? I heard that question before for this very application. I will paste an answer with code for this scenario below.
    – JBartlau
    Aug 27, 2018 at 9:19

1 Answer 1

2

The QR code itself has no fixed encoding. You may try to set the ECI using

LL.Core.LlXSetParameter(LlExtensionType.Barcode, "QRCode", "ECI", "0000026");

Depending on the scanner type this might help or not. In order to make sure to UTF-8 encode the contents you should pass them byte-by-byte - this circumvents any problems between the passing and rendering. A designer extension function that handles this job would be wired up like this:

Designer Function

The evaluation code would read:

private void designerFunction1_EvaluateFunction(object sender, EvaluateFunctionEventArgs e)
{
    string input = e.Parameter1.ToString();

    var utf8 = Encoding.UTF8;
    byte[] utfBytes = utf8.GetBytes(input);
    StringBuilder barcodeContent = new StringBuilder();
    foreach (byte b in utfBytes)
    {
        barcodeContent.AppendFormat("~d{0:000}", b);
    }
    e.ResultValue = barcodeContent.ToString();
    e.ResultType = LlParamType.String;
}

Then use EncodeAsUTF8 for your barcode's content and your should be fine.

1
  • Starting with version 28, there's a built-in Designer function UTF8Encode$ that does the trick.
    – JBartlau
    Dec 22, 2022 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.