Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print Chinese(BIG5) text #1072

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
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