Encoding UTF-8 characters in a QR Code

From version 28 you can use the designer function UTF8Encode$ to display umlauts correctly in QR codes (and Datamatrix codes). Example: Barcode(UTF8Encode$("ÄÖÜ"), "QRCode").

For older versions:

The QR code itself has no fixed encoding. In order to make sure to UTF-8 encode the contents you should pass them byte-by-byte - this circumvents any problems between passing the content, rendering it as QR code and scanning it. A designer extension function that handles this job would be wired up like this:


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(<actual content>) for your barcode’s content. The same procedure would work for the DataMatrix barcode as well.

If there are no designer functions available in your programming language you can of course pass a variable/field with the converted content ("~d…~d…", where “…” represents the UTF8 bytes).