37-chinese.php 1009B

12345678910111213141516171819202122232425
  1. <?php
  2. /*
  3. * This is an example of printing chinese text. This is a bit different to other character encodings, because
  4. * the printer accepts a 2-byte character encoding (GBK), and formatting is handled differently while in this mode.
  5. *
  6. * At the time of writing, this is implemented separately as a textChinese() function, until chinese text
  7. * can be properly detected and printed alongside other encodings.
  8. */
  9. require __DIR__ . '/../../vendor/autoload.php';
  10. use Mike42\Escpos\CapabilityProfile;
  11. use Mike42\Escpos\Printer;
  12. use Mike42\Escpos\PrintConnectors\FilePrintConnector;
  13. $connector = new FilePrintConnector("/dev/usb/lp1");
  14. $profile = CapabilityProfile::load("default");
  15. $printer = new Printer($connector);
  16. // Example text from #37
  17. $printer -> textChinese("艾德蒙 AOC E2450SWH 23.6吋 LED液晶寬螢幕特價$ 19900\n\n");
  18. // Note that on the printer tested (ZJ5890), the font only contained simplified characters.
  19. $printer -> textChinese("示例文本打印机!\n\n");
  20. $printer -> close();