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

For those who need encoding, use it. #75

Open
siadiawork opened this issue Sep 3, 2021 · 1 comment
Open

For those who need encoding, use it. #75

siadiawork opened this issue Sep 3, 2021 · 1 comment

Comments

@siadiawork
Copy link

siadiawork commented Sep 3, 2021

https://colorscripter.com/s/MDRJWkt

TextCmd.php

TextCmd.php.txt

@mdestafadilah
Copy link

why not pasted here 👍

<?php
namespace ReceiptPrintHq\EscposTools\Parser\Command;
use ReceiptPrintHq\EscposTools\Parser\Command\Command;
use ReceiptPrintHq\EscposTools\Parser\Command\TextContainer;
//class TextCmd extends Command implements TextContainer
//{
//    private $str = "";
//
//    public function addChar($char)
//    {
//        if (isset(Printout::$tree[$char])) {
//            // Reject ESC/POS control chars.
//            return false;
//        }
//        $this -> str .= iconv('CP437', 'UTF-8', $char);
//        return true;
//    }
//
//    public function getText()
//    {
//        return $this -> str;
//    }
//}
//
class TextCmd extends Command implements TextContainer
{
    private $str = array();
    public function addChar($char)
    {
        if (isset(Printout::$tree[$char])) {
            // Reject ESC/POS control chars.
            return false;
        }
        array_push($this -> str , $char);
        //error_log(implode("", $this -> str));
        //error_log($char);
        return true;
    }
    public function getText()
    {
        //error_log(iconv("EUC-KR", "UTF-8", implode("", $this -> str)));
        return iconv("EUC-KR", "UTF-8", implode("", $this -> str));
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants