Skip to content

symfony/console and unicode text on Win10 console #49942

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

Closed
aleksandr-shevchenko opened this issue Apr 5, 2023 · 5 comments
Closed

symfony/console and unicode text on Win10 console #49942

aleksandr-shevchenko opened this issue Apr 5, 2023 · 5 comments

Comments

@aleksandr-shevchenko
Copy link
Contributor

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

@stof
Copy link
Member

stof commented Apr 5, 2023

which OS are you using (to know which branch of this code is actually executed) ?

@aleksandr-shevchenko
Copy link
Contributor Author

Windows 10

@aleksandr-shevchenko aleksandr-shevchenko changed the title symfony/console and unicode text symfony/console and unicode text on Win10 console Apr 5, 2023
@maxbeckers
Copy link
Contributor

I cannot reproduce this bug,
On git-bash using windows 10:
Screenshot 2023-04-17 120129

And on CMD:
Screenshot 2023-04-17 120213

@aleksandr-shevchenko
Copy link
Contributor Author

@maxbeckers
The broken encoding bug has been fixed in 6.2.x-dev (see #49987).
Try <=6.2.8

@maxbeckers
Copy link
Contributor

Ah, thanks ... then this issue can be closed IMHO. //cc @nicolas-grekas

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

No branches or pull requests

5 participants