CAPS Universe documentation  1.0.4
All you need to know to be successful
The Printer Data Encoding Method "3"

This is a regular PCL encoding method. Encoding happens by sending a line delta regarding to the previous line content. All bytes matching in both lines are skipped. If both lines are matching, no data is sent at all.

In the wire data (regular PCL3) the line's data starts with a leading ASCII number and the char 'w' and then the line's delta data follows. The leading ASCII number defines the line's delta data byte count. If both lines are matching just a 'w' is sent (e.g. no leading ASCII number). That's all.

Each line delta gets encoded as:

7654 3210 [offset overflow] \<pattern\>…
oooc cccc
   ^_^^^^_ (Part of) 'offset'
^^^_______ 'count'

In each of these delta's, count can define up to eight bytes which follows immediately (e.g. the encoded count value must be incremented first, '0' means one byte). offset is unlimited.

If offset == 0b11111 then 'overflow' bytes follow, which must be added to the offset value.

Examples for the 'offset':

xxx1 1111 1111 1111 0001 0000  <pattern>
                    ^^^^_^^^^_ Overflow terminator at the same time
   ^_^^^^_^^^^_^^^^_^^^^_ Offset sum is: 31 + 255 + 16

xxx1 1111 0001 0000 <pattern>
          ^^^^_^^^^_ Overflow terminator at the same time
   ^_^^^^_^^^^_ Offset sum is: 31 + 16

This kind of delta will now fill the line with count bytes from the <pattern>… beginning at the line offset + offset from this delta. After doing so, the line offset gets incremented by offset + count (to be used by the next delta as its new line offset).