Skip to content

Outputing a Binary in Symfony Console #61326

@tmbenhura

Description

@tmbenhura

Symfony version(s) affected

7.3.2

Description

Output to the console has special characters transformed when explicitly using the OutputInterface::OUTPUT_RAW.

The line-feeds are converted to control linefeeds, therefore corrupting the binary content.

How to reproduce

use Jasper4PHP\Builders\ReportBuilder;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Formatter\OutputFormatterStyleInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
    name: 'export',
    description: 'Export a photo',
)]
class ExportCommand extends Command
{
    public function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->write("HELLO\r\nWORLD", false, OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_NORMAL);

        return Command::SUCCESS;
    }
}

Possible Solution

No response

Additional Context

I'm running this on Windows 11.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy