clrghouz/app/Console/Commands/BBS/ANSIEncode.php

42 lines
699 B
PHP
Raw Normal View History

<?php
2024-05-28 02:43:58 +00:00
namespace App\Console\Commands\BBS;
use Illuminate\Console\Command;
use App\Classes\ANSI;
class ANSIEncode extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
2024-05-28 02:43:58 +00:00
protected $signature = 'bbs:ansi:encode'
.' {file : ANS file to encode}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Encode ANS file to custom binary';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
foreach (ANSI::binary($this->argument('file')) as $line) {
foreach (str_split(bin2hex($line),2) as $y)
echo hex2bin($y);
echo "\r";
}
return self::SUCCESS;
}
}