Unicode characters on ZPL printer

前端 未结 10 2032
既然无缘
既然无缘 2020-11-27 04:32

I have the task of re-designing a system to print shipping labels, using a networked Zebra GK420T. I have been able to send ZPL print jobs to it perfectly fine, but I cannot

相关标签:
10条回答
  • 2020-11-27 04:53

    I had the same problem, you should add an ^FH(Field Hexadecimal Indicator) before any ^FD(Field Data) command that contains special characters, in my case I need spanish chars so I had to use ^CI28(Change International Font/Encoding)

    UTF 8 HEX codes list

    sample: to print Alvaro Jesús Pérez Peñaranda we need to convert those special characters to UTF 8 Hex code and add an _ before each code, this is the result: Alvaro Jes_c3_bas P_c3_a9rez Pe_c3_b1aranda

    ^XA
    
    ^CI28
    ^FO60,75
    ^ASN,36,20^FH^FDAlvaro Jes_c3_bas P_c3_a9rez Pe_c3_b1aranda^FS
    
    ^XZ
    
    0 讨论(0)
  • 2020-11-27 04:57

    In latest firmware versions (since v x.16.x) you can use ^CI33 for codepage Windows-1251 encoded text (and other codepages) without ^FH. See manual

    0 讨论(0)
  • 2020-11-27 05:04

    Russian and many other characters can be printed using the free Zebra swiss unicode font. It is already included in most printers as TT0003M_ and supports Roman, Cyrillic, Eastern European, Turkish, Arabic, Hebrew.


    For printing languages like Japanese or Chinese, which have thousands of characters, you need a printer with at least 23 MB of free memory and a TrueType font file you can upload (they call it download).

    This file can be bought from Zebra (and they say you need 64 MB), but I was also very successful with a very old TTF file found on my Windows 7 system in the Fonts folder: ARIALUNI.TTF 1.01 (23.275.812 Bytes), Arial Unicode MS. It was installed by a MS Office installation and is maybe not licensed for this use.

    Most likely you can also use other TTF files, but I tried only this one.

    While ZPL-printing on this Zebra printer worked without any original driver (just generic text only), for the font installation the driver was needed. If anyone knows how to send the TTF file to the printer without driver, please comment.

    I installed the Zebra Setup Utilities, which include a Fonts Downloader. Click new, then add the font (must be installed in the system), and ignore the message that 226 characters are included. Also ignore that if you configure a test string with Unicode characters, it will not display correctly. You are beeing asked if you want to download now and it takes a long time.

    You can check the installation by listing the directory contents (Administration web page or printout). There the font appears as ARI000.TTF in my case.


    To print, you need to send the ZPL text as UTF-8. You can copy this example to notepad and select UTF-8 in the save dialog:

    ^XA
    ^LH100,150
    ^CWT,E:ARI000.FNT
    ^CFT,30,30
    ^CI28
    ^FT0,0^FH^FDyour unicode characters here^FS
    ^XZ
    

    Then, for testing, you can use a simple copy command to send it to the printer:

    In case of USB you need to share this printer in the network first.

    Then net use lpt1: \\localhost\sharename and copy file.txt lpt1

    We tested with many common Japanese and Chinese symbols and it works very well with high quality, on a ZT230 printer with 32 MB flash.

    0 讨论(0)
  • 2020-11-27 05:05

    Your "До свидания" were probably in cp1251. Encode it in actual UTF-8 and try again. Blank spaces are a good indicator that you have an encoding problem.

    Verified with v56.17.112 firmware and ^A@N,,,E:TT0003M_.FNT

    0 讨论(0)
  • 2020-11-27 05:07

    You can replace character that greater then one byte to UTF-8 hex string with underscore like "ћ => _D1_9B". Sample code below;

     var zpl_code = "^XA" +
            "^LH100,150" +
            "^CWT,E:TT0003M_.FNT" +
            "^CFT,30,30" +
            "^CI28" +
            "^FT0,0^FDTesting 1 2 3^FS" +
            "^FT0,50^FDДо свидания^FS" +
            "^FT0,100^B3^FDAAA001^FS" +
            "^XZ";
            var unicodeCharacterList = zpl_code.Distinct()
                .Select(c => c.ToString())
                .Select(c => new { key = c, UTF8Bytes = Encoding.UTF8.GetBytes(c) })
                .Where(c => c.UTF8Bytes.Length > 1);
    
            foreach (var character in unicodeCharacterList)
            {
                var characterHexCode = string.Join("", character.UTF8Bytes.Select(c => "_" + BitConverter.ToString(new byte[] { c }).ToLower()).ToArray());
    
                zpl_code = zpl_code.Replace(character.key, characterHexCode);
            }
    

    This code set zpl_code variable to below output

    ^XA
    ^LH100,150
    ^CWT,E:TT0003M_.FNT
    ^CFT,30,30
    ^CI28
    ^FT0,0^FDTesting 1 2 3^FS
    ^FT0,50^FD_d0_94_d0_be _d1_81_d0_b2_d0_b8_d0_b4_d0_b0_d0_bd_d0_b8_d1_8f^FS
    ^FT0,100^B3^FDAAA001^FS
    ^XZ
    
    0 讨论(0)
  • 2020-11-27 05:07

    if you want print Russian Cyrillic letters using :TT0003M_.FNT, you should save commands to file with UTF-8 encoding!

    ^XA
    ^LH100,150
    ^CWT,E:TT0003M_.FNT
    ^CFT,30,30
    ^CI28
    ^FT0,0^FH^FDTesting 1 2 3^FS
    ^FT0,30^FH^FDДо свидания^FS
    ^FT0,100^B3^FDAAA001^FS
    ^XZ
    

    Then, using command line you can send it to printer port. An example: copy C:\Users\xxx\Desktop\test_ru.txt com1

    I hope that will help...

    0 讨论(0)
提交回复
热议问题