44-pound-symbol-star-tsp650.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /* Example of printing the GBP pound symbol on a STAR TSP650
  3. *
  4. * In this example, it's shown how to check that your PHP files are actually being
  5. * saved in unicode. Sections B) and C) are identical in UTF-8, but different
  6. * if you are saving to a retro format like Windows-1252.
  7. */
  8. // Adjust these to your environment
  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("php://stdout");
  14. // Start printer
  15. $profile = CapabilityProfile::load("simple");
  16. $printer = new Printer($connector, $profile);
  17. // A) Raw pound symbol
  18. // This is the most likely thing to work, and bypasses all the fancy stuff.
  19. $printer -> textRaw("\x9C"); // based on position in CP437
  20. $printer -> text(" 1.95\n");
  21. // B) Manually encoded UTF8 pound symbol. Tests that the driver correctly
  22. // encodes this as CP437.
  23. $printer -> text(base64_decode("wqM=") . " 2.95\n");
  24. // C) Pasted in file. Tests that your files are being saved as UTF-8, which
  25. // escpos-php is able to convert automatically to a mix of code pages.
  26. $printer -> text("£ 3.95\n");
  27. $printer -> cut();
  28. $printer -> close();