EscPosEncoder { public static byte[] encodeLength(int length) { byte highByte = (byte)(length >> 8); byte lowByte = (byte)(length & 0xff); return new byte[] { lowByte, highByte }; }  static byte[] encodeLength(int length); static byte[] qrCodeModule(byte module); static byte[] qrCodeCorrection(CorrectionLevel cl); static byte[] qrCodeStore(String data); static byte[] qrCodePrint();  }
@Test public void itShouldEncodeLength() throws Exception { byte[] length = EscPosEncoder.encodeLength(7000); assertEquals(0x58, length[0]); assertEquals(0x1b, length[1]); byte[] length2 = EscPosEncoder.encodeLength(255); assertEquals((byte)0xff, length2[0]); assertEquals(0x00, length2[1]); byte[] length3 = EscPosEncoder.encodeLength(256); assertEquals(0x00, length3[0]); assertEquals(0x01, length3[1]); }