3

Printing to a Zebra ZQ510 using "line_print" mode on continuous feed receipt paper.

! U1 setvar "ezpl.media_type" "continuous"  \r\n  
! U1 setvar "device.languages" "line_print" \r\n 
! U1 ENCODING UTF-8  \r\n
! U1 SETLP 5 0 28  \r\n
! U1 PAGE-WIDTH 580  \r\n
! U1 BEGIN-PAGE \r\n
Has the person to be vaccinated ever had      \r\n
Guillain-Barré syndrome?: \r\n
! U1 END-PAGE \r\n

The above commands are output to the printer connection using this Objective-C code to encode the binary data as UTF-8:

-(void) printCommands: (NSString*) tPrintCommands {
    ...
    [aPrinterConn write:[tPrintCommands dataUsingEncoding:NSUTF8StringEncoding] error:&aError];
    ...
}

But instead of "Barré", I get "Barré" on the printout. Seems the Unicode "é" is being treated as 2 separate characters by the printer.

I have tried substituting ! U1 ENCODING UTF-8 \r\n with ! U1 COUNTRY UTF-8 \r\n and I have positioned ! U1 ENCODING UTF-8 \r\n before and after BEGIN-PAGE. Same result every time.

Chuck Krutsinger
  • 2,830
  • 4
  • 28
  • 50
  • Does this doc answer your question: https://www.zebra.com/us/en/support-downloads/knowledge-articles/ait/How-to-Printing-Chinese-Characters-in-QR-code-using-ZPL.html Excerpt: `Do note that this is using encoding ^CI0 and reading the UTF-8 encoded characters from the text file itself which doesn't require any Chinese font in printer! And in ^FD command, B0050 means 8-bit byte mode, ‘0050’ is the number of characters, this value must be greater than the actual value and must be exactly 4 decimal digits.` – Jay Mar 10 '20 at 23:45
  • @Jay. Thanks, but that answer only applies to ZPL, which is incompatible with the line_print mode that I need to use for my application. – Chuck Krutsinger Mar 11 '20 at 03:26
  • Is it possible that somehow you've saved the file containing your sample instructions (that you pasted) got saved with a latin (or other non-utf8) encoding? The É to é problem is common and has its root in how binary data is interpreted by different encodings. See https://www.weblogism.com/item/270/why-does-e-become-a If you are running on Windows, there is a chance your terminal does not use UTF-8 by default. You can change the encoding of your current session by running `chcp 65001` – Everett Mar 20 '20 at 06:16
  • @Everett I added the code snippets so that you can see that the data is UTF-8 encoded. – Chuck Krutsinger Mar 20 '20 at 14:32
  • It maybe a font issue. What kind of font is the printer using? – tukan Apr 02 '20 at 07:37
  • @tukan Using a built in font, #5. See `! U1 SETLP 5 0 28`. Wanting to stay simple and use built in fonts if possible. I see in the manual that the font includes characters 20-FF. I'm now thinking that means there is no UTF, only ASCII. Maybe I can use the ASCII accented character 130 if I can figure out how to recode it. – Chuck Krutsinger Apr 02 '20 at 14:25
  • Anyone know how to convert a UTF-8 vowel with accents into its equivalent ASCII. For example, é should convert to ASCII 130. – Chuck Krutsinger Apr 02 '20 at 14:43
  • @ChuckKrutsinger try encoding out of objective C with `NSWindowsCP1252StringEncoding`. 1252 is usually the "default" codepage. Keep the country USA (or UK or whatever). – yhyrcanus Apr 02 '20 at 15:31
  • That is not that simple. First of all the ordinary ASCII has only 127 positions. You want an extended ASCII character. You can try changing encoding but that would mean that you have to use ASCII ENCODING instead of the UTF8, but that would still require the font to support it. If the font does not support extended ASCII then you can't do anything. If you want to use UTF8 you need to have a font that supports it, nothing else will help. – tukan Apr 02 '20 at 17:52
  • @tukan The manual says that the font supports characters up through FF (255). I just haven't yet found a way to convert the UTF-8 string that I have into an extended ASCII character in Objective-C. – Chuck Krutsinger Apr 02 '20 at 19:54
  • I understood the supported characters, but you have different characters on 82 (130) for each code page make sure you have a correct code page for your font so you will get correct character. Also you probably want to replace `U1 ENCODING UTF-8` with the `COUNTRY FRANCE` and try to print `TEXT 4 0 0 35 #$@[\]^‘{|}~`. To convert UTF8 to ASCII check this SO answer - https://stackoverflow.com/questions/20031873/byte-array-in-objective-c-with-ascii-encoding – tukan Apr 03 '20 at 08:34

0 Answers0