Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Mike42/Escpos/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -999,16 +999,17 @@ public function text(string $str)

/**
* Add Chinese text to the buffer. This is a specific workaround for Zijang printers-
* The printer will be switched to a two-byte mode and sent GBK-encoded text.
* The printer will be switched to a two-byte mode and sent GBK/BIG5-encoded text.
*
* Support for this will be merged into a print buffer.
*
* @param string $str Text to print, as UTF-8
* @param string $encoding Encoding of Chinese text such as BIG-5, GB18030
*/
public function textChinese(string $str = "")
public function textChinese(string $str = "", string $encoding = "GBK")
{
$this -> connector -> write(self::FS . "&");
$str = \UConverter::transcode($str, "GBK", "UTF-8");
$str = \UConverter::transcode($str, $encoding, "UTF-8");
$this -> buffer -> writeTextRaw((string)$str);
$this -> connector -> write(self::FS . ".");
}
Expand Down