mike42/escpos-php UTF-8 no print Cyrillic

2019-08-25 02:01发布

问题:

I like to print Cyrillic on my XPRINTER XP-58 pos printer.

I tried below code but it doens't print all the letters and if so it prints the print-out badly. This is what I got as a result of this code, but not all letters are missing: ---- Ѕ Ј К Љ Њ Ќ Ѓ --------- LETTERS

If there is anyone with experience in this please help me. Thank you in advance,

My code:

public function index()
{
    $data = "";
    $data['test'] = array(['А Б В Г Д Ѓ Е Ж З Ѕ И Ј К Л Љ М Н Њ О П Р С Т Ќ У Ф Х Ц Ч Џ Ш']);
    $this->load->library("EscPos.php");
    try {        
        $connector = new Escpos\PrintConnectors\WindowsPrintConnector("XP-58");
        $profile = Escpos\CapabilityProfiles\DefaultCapabilityProfile::getInstance();
        $printer = new Escpos\Printer($connector,$profile);
        foreach ($data['test'] as $artikli){
            $printer -> text(iconv("UTF-8","GBK//IGNORE", "$artikli[0]") . "\n");
        }
        $printer -> text("\n\n\n");
        $printer -> cut();

        /* Close printer */
        $printer -> close();
    } catch (Exception $e) {
        echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
    }
    $this->load->view('welcome_message');
}