Search code examples
htmlzebra-printers

  is getting replaced with á on labels


I have the following code

<td colspan="@missingGridColumnCount">**&nbsp;<span translate="MissingItems">.MissingInstruments</span>&nbsp;**</td>

This prints correctly through the browser but when I print to my Zebra printer, I get the following on the label:

**_áMissing Items_á**

I have looked through Zebra Label documentation but cannot find a way to convert this or accept the &nbsp; for the labels.


Solution

  • This is a character encoding issue.

    The probable chain of events is this:

    • The browser is rendering the &nbsp; entity into the Unicode code point "U+00A0 NO-BREAK SPACE".
    • This is being encoded in UTF-8, as the sequence of bytes C2 A0.
    • These bytes are being interpreted by the Zebra printer according to Code page 850, where C2 is mapped to "┴" (U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL) and A0 to "á" (U+00E1 LATIN SMALL LETTER A WITH ACUTE).

    In code page 850, a non-breaking space is represented by the byte FF.

    You may be able to tell the whatever is interpreting the HTML to use Code page 850 instead of UTF-8, and it will send the byte sequences the printer is expecting. You will need to make sure your input doesn't contain any literal UTF-8 - escape all non-ASCII characters as HTML entities.

    Otherwise, you will need to substitute byte-wise before sending to the printer, or encode in some other way.