php / php/php-src

declare(encoding=...) ignored because Zend multibyte feature is turned off by settings for ASCII or UTF-8

Open
#21,538 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

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:

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:

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=1 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 for 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Reproduce the warning with zend.multibyte set to 0 and 1 using the listed declare(encoding=...) values, then determine the intended warning behavior; done means the agreed behavior is implemented and covered by regression checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.