mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.57k stars 862 forks source link

Turkish character output on GP-F80300II #319

Closed shenol closed 6 years ago

shenol commented 7 years ago

What should I do to print Turkish characters?

ş ü ö İ ğ ı ç

<?php
header('Content-Type: text/html; charset=utf-8');
require __DIR__ . '\vendor\autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;

try {

    $connector = new WindowsPrintConnector("ADS");
    $printer = new Printer($connector);
    $printer -> text("Pijamalı hasta, yağız şoföre çabucak güvendi.\n");
    $printer -> cut();
    $printer -> close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
mike42 commented 7 years ago

Could you let me know what type of printer do you have, whether it supports a code page which can encode Turkish characters, and what output you got when you ran this snippet?

The list of code pages can usually be found in the vendor documentation by printing a self-test page.

shenol commented 7 years ago

whatsapp image 2017-03-17 at 16 42 15

printer: grpinter f80300ii

mike42 commented 7 years ago

Ok. As a quick check, I don't think printer can print Turkish characters. Your best bet would be one of these these legacy code pages-

But the vendor documentation I found lists these pages:

# Page
0 PC437 [U.S.A.Standard Europe]
1 Katakana
2 PC850:Multilingual
3 PC860:Portuguese
4 PC863 [Canadian French]
6 PC865:Nordic
7 Greek
8 Hebrew
9 PC755:East Europe
10 Iran
16 WPC1252
17 PC866:Cyrillic 2
18 PC852:Latin2
19 PC858
20 IranII
21 Latvian

(Source: GP-80XXX Programmer Manual v6)

So to print these characters, you would need to use a work-around that involves generating images with a Unicode font. A user recently had the same problem printing Vietnamese, so you will find some great information on the issue tracker already.

I'll add a link here once that work-around is in the FAQ.

Also, if I post the script to do it, would you be willing to post back the contents of a few of these code pages to help me identify them?

shenol commented 7 years ago

We do not have a chance to print directly. It works with other language plugin support. It would be a great printing solution for my cloud based application. @mike42 Can you write a sample ? It did not work out.

shenol commented 7 years ago

Sound check :)

mike42 commented 6 years ago

Going to close this off as there isn't anything much we can do here.