Bug #81598 [PATCH]: Cannot input unicode characters in PHP 8 interactive shell

From: Date: Tue, 09 Nov 2021 11:07:20 +0000
Subject: Bug #81598 [PATCH]: Cannot input unicode characters in PHP 8 interactive shell
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237647@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81598&edit=1

 ID:                 81598
 Patch added by:     nikic@php.net
 Reported by:        7snovic at gmail dot com
 Summary:            Cannot input unicode characters in PHP 8 interactive
                     shell
 Status:             Verified
 Type:               Bug
 Package:            CGI/CLI related
 Operating System:   Ubuntu 20
 PHP Version:        8.0Git-2021-11-08 (snap)
 Block user comment: N
 Private report:     N

 New Comment:

The following pull request has been associated:

Patch Name: Fix bug #81598: Use C.UTF-8 as LC_CTYPE locale by default
On GitHub:  https://github.com/php/php-src/pull/7635
Patch:      https://github.com/php/php-src/pull/7635.patch


Previous Comments:
------------------------------------------------------------------------
[2021-11-09 10:39:38] nikic@php.net

I looked into the editline implementation a bit (apparently available at https://thrysoee.dk/editline/ as a tar.gz file only -- no
version control) and it seems to be based entirely around wchar functionality, which is indeed
locale-based.

Something I tried and that seems to work is to use the "C.UTF-8" locale. I believe that
should both make mbrtowc() work fine, and not introduce any locale-sensitivity in the single-byte
functions used by PHP at the same time.

------------------------------------------------------------------------
[2021-11-08 16:28:48] nikic@php.net

From a quick test, calling setlocale() at the start of the session doesn't seem to work. It
would be pretty bad UX as well.

Though that gives me a tiny bit of hope that maybe it's sufficient to have the locale set
during some kind of startup procedure, and we can use the C locale afterwards.

------------------------------------------------------------------------
[2021-11-08 16:14:52] cmb@php.net

> The relevant change here is probably that PHP 8 no longer
> inherits the ctype locale from environment.

Ah, so this would be rather a documentation issue, telling users
to call setlocale() at the start of their session?

------------------------------------------------------------------------
[2021-11-08 16:07:16] nikic@php.net

(Undoing concurrent status changes)

------------------------------------------------------------------------
[2021-11-08 16:06:54] nikic@php.net

I can reproduce this. And I can also reproduce on 7.4 when running with "LANG=C php7.4
-a". The relevant change here is probably that PHP 8 no longer inherits the ctype locale from
environment.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=81598


--
Edit this bug report at https://bugs.php.net/bug.php?id=81598&edit=1


Thread (13 messages)

« previous php.bugs (#237647) next »