[php-src] Issue #21538: declare(encoding=...) ignored because Zend multibyte feature is turned off by settings for ASCII or UTF-8

[email protected] (LLyaudet)
Newsgroups php.bugs
Message-ID <28cqirwWk6AYUPOmuSRk42Kvwj8bazRtRQJcFksQ0uo@main.internal.php.net>
Issue: https://github.com/php/php-src/issues/21538
Author: LLyaudet

### Description

Hello :),

Assume you mix files in distinct encodings in various projects.
If some are in ISO-8859-1 or ISO-8859-15 for example,
and others are in UTF-8.
You can have the habit to always use:
```php
declare(encoding='ISO-8859-1')
// or
declare(encoding='ISO-8859-15')
// or
declare(encoding='UTF-8')
// or
declare(encoding='ASCII')
```
However, if `zend.multibyte=0` and you use files with:
```php
declare(encoding='UTF-8')
// or
declare(encoding='ASCII')
```
you will get
```
PHP Warning:  declare(encoding=...) ignored because Zend multibyte feature is turned off by settings in
```
which makes you want to remove them.

And if `zend.multibyte=0` and you use files with all declare(encoding=...)
you will get no warning.

I would prefer that PHP states clearly what is preferred when the files can be used separately,
and hence some of these files without Zend multibyte:
- If the prefered solution is to always have the declare(encoding=...) directive,
  then the warning
  ```
  PHP Warning:  declare(encoding=...) ignored because Zend multibyte feature is turned off by settings in
  ```
  should be suppressed with encodings that do not require multibyte.
- If the prefered solution is to never have the declare(encoding=...) directive for encodings that don't need it,
  then the warning should be distinct:
  ```
  PHP Warning:  declare(encoding='UTF-8') is useless, remove it.
  ```
  and appear whatever the value of Zend multibyte configuration.

Thanks, best regards,
    Laurent Lyaudet
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.