Skip to content

symfony/console and unicode text on Win10 console #49942

Closed
@aleksandr-shevchenko

Description

@aleksandr-shevchenko

Symfony version(s) affected

6.2.8

Description

echo can print unicode text to windows console, but symfony/console not.

How to reproduce

I found a place where the windows console gets corrupted and it can no longer display unicode text. Please fix it.

symfony\console\Terminal.php:

    private static function initDimensions()
    {
        echo "before initDimensions() - йфяЙФЯёЁ üÜiİöÖğĞıIəƏçÇşŞ" . PHP_EOL;
        if ('\\' === \DIRECTORY_SEPARATOR) {
            if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
                // extract [w, H] from "wxh (WxH)"
                // or [w, h] from "wxh"
                self::$width = (int) $matches[1];
                self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
            } elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
                // only use stty on Windows if the terminal does not support vt100 (e.g. Windows 7 + git-bash)
                // testing for stty in a Windows 10 vt100-enabled console will implicitly disable vt100 support on STDOUT
                self::initDimensionsUsingStty();
            } elseif (null !== $dimensions = self::getConsoleMode()) {
                // extract [w, h] from "wxh"
                self::$width = (int) $dimensions[0];
                self::$height = (int) $dimensions[1];
            }
        } else {
            self::initDimensionsUsingStty();
        }
        echo "after initDimensions() -- йфяЙФЯёЁ üÜiİöÖğĞıIəƏçÇşŞ" . PHP_EOL;
    }

ss_2023_04_05__15_28_10

Possible Solution

No response

Additional Context

No response

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