dsbpaqt61965 2016-01-19 09:34
浏览 93

我不能用sewoo热敏打印机打印泰语作为php的原始数据

i am trying to print thai language on thermal printer sewoo SLK-T21EB. I can print english language and i can change font size of english language also with esc/pos commands. But when I try to print thai language it prints something i cannot understand. I am using php language to do this. i have to print receipts for my app.If i try to print thai language with some other program in windows, i can print. I am using wamp server. My code is

<?php
$ph = printer_open("THERMAL Receipt Printer");
echo "$ph";
printer_set_option($ph, PRINTER_MODE, "RAW");
printer_set_option($ph, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_CUSTOM);
printer_set_option($ph, PRINTER_PAPER_LENGTH, 50);
printer_set_option($ph, PRINTER_COPIES, 1);
printer_start_doc($ph, "PHP Document");
printer_start_page($ph);

const ESC = "\x1b";
const FS = "\x1c";
const GS="\x1d";
const NUL="\x00";

$InitializePrinter= ESC."@";
$bigchar=ESC."E".chr(1);
$bigsize=GS."!".chr(1111);
printer_write($ph, $InitializePrinter);
printer_write($ph, $bigchar); //bold
printer_write($ph, $bigsize); //size
printer_write($ph, "data string to print");
printer_write($ph, "ฟกดเพำ");
printer_end_page($ph);
printer_end_doc($ph);
printer_close($ph);
?>

please help...

  • 写回答

1条回答 默认 最新

  • duanheyi7147 2016-02-24 21:44
    关注

    The problem seems to be either that you haven't told the printer what kind of languages it should be printing or that you haven't encoded the Thai string propperly.

    You could try

    printer_write($ph, utf8_encode("ฟกดเพำ"));
    

    Or you could try a command which will set the language format for the printer to Thai. Since i did not see such a command in your post. I had a similar problem when trying to print swedish characters in Java. But i used bytes instead of strings :)

    According to an answer given here can i change printer_write in another language? you can not change the language of the printer from php, perhaps you could change the language by going to the settings for the printer ? Anyhow let me know if you got this solved.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题