B64 and Z64 Encoding

B64 and Z64 Encoding

These download encodings, B64 and Z64, are created as drop-in replacements for the existing ASCII hexadecimal encoding.
B64 encoding do the following:
  • Encode the compressed data using the MIME Base64 algorithm.
  • Calculate a CRC across the encoded data.
  • Add a unique header to differentiate the new format from the existing ASCII hex encoding.
Z64 encoding do the following:
  • Compress the data using the LZ77 algorithm.
  • Encode the compressed data using the MIME Base64 algorithm.
  • Calculate a CRC across the encoded data.
  • Add a unique header to differentiate the new format from the existing ASCII hexadecimal encoding.
The data field have this format:
:id:encoded_data:crc
Parameter
Details
:id
The identifying string B64 or Z64.
:iencoded_data
Data to download, compressed with LZ77 (if the id parameter is set to Z64) and encoded with Base64.
:crc
Four hexadecimal digits representing the CRC calculated over the :encoded_data field.
The printer calculates a CRC across the received data bytes and compare this to the CRC in the header. A CRC mismatch is treated as an aborted download.
The B64 and Z64 encodings can be used in place of the ASCII hexadecimal encoding in any download command. The commands are:
~DB
Download Bitmap Font
~DE
Download Encoding
~DG
Download Graphic
~DL
Download Unicode Bitmap Font
~DS
Download Scalable Font
~DT
Download TrueType Font
~DU
Download Unbounded TrueType Font
^GF
Graphic Field (with compression type set to “ASCII hex”)
The
~DB
(Download Bitmap Font) command can use the new encodings in place of the ASCII hexadecimal encoding in data sub-fields. Each character is encoded individually. However, for small amounts of data, the identifying B64 or Z64 header and trailing CRC may negate any gains made by using the new format.
For backward compatibility, the
^HG
(Host Graphic) command uses the ASCII hexadecimal encoding. It does not use the new encodings.