-
Notifications
You must be signed in to change notification settings - Fork 887
Text encoding
Michael Billington edited this page Dec 15, 2019
·
11 revisions
This method is used by default.
Example:
<?php
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\Printer;
$profile = CapabilityProfile::load("default");
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector, $profile);
$printer -> text("Pchnąć w tę łódź jeża lub ośm skrzyń fig.\n");
$printer -> cut();
$printer -> close();How it works:
- Each printer has glyphs from a number of legacy code pages, numbered 0-255 on the printer. The exact mapping varies considerably between printers.
- The developer finds out which code pages their printer supports, and checks that they are listed correctly in the ESC/POS printer database. There is information about adding a printer here.
- In PHP code, the matching profile is loaded into a
CapabilityProfileobject. Thedefaultprofile is used if none is specified. - UTF-8 text is then passed to
$printer -> text('...'), and the library will convert it character-by-character.
Compatibility:
- This works for most European languages, and is configured out-of-the box to match the code pages present on common Epson-branded printers.
- Printers which have an uncertain code page mapping (eg. not listed correctly in the receipt printer database) will not produce usable output outside of ASCII text.
- If a printer does not have the glyphs that you are trying to use, then this method will not work.
- If there is not a 1-1 relationship between characters and glyphs in your script, then this method will not produce usable output. This includes scripts which require the use of presentation forms, composing characters or bi-directional text (eg. Thai, Khmer, Indian scripts, Arabic).
Example uses
- #848 - Hebrew
Example:
// TODO example here.How it works:
- TBD
Compatibility:
- TBD
Example uses:
Example:
// TODO example here.How it works:
- TBD
Compatibility:
- TBD
Example:
// TODO example here.How it works:
- TBD
Compatibility:
- TBD